http,python-3.x,ipv6,uwsgi , uWSGI --http :80 doesn't listen IPv6 interface

uWSGI --http :80 doesn't listen IPv6 interface


Tag: http,python-3.x,ipv6,uwsgi

Why doesn't uWSGI listen on IPv6 interface, even if system is 100% IPv6 ready? As far as I could see there aren't parameters nor documentation covering this issue.


In your INI config file specify something like this


socket = [::]:your_port_number

Or from the CL,

./uwsgi -s [::]:your_port_number

The server shall now listen along all the interfaces (including IPv4, if the underlying OS supports dual stack TCP sockets)


Python 3.4: List to Dictionary

I have a string as follows : ['Total Revenue', 31821000, 30871000, 29904000, 'Cost of Revenue', 16447000, 16106000, 15685000, 'Gross Profit', 15374000, 14765000, 14219000, 'Research Development', 1770000, 1715000, 1634000, 'Selling General and Administrative', 6469000, 6384000, 6102000, 'Non Recurring', '-', '-', '-', 'Others', '-', '-', '-', 'Total Operating Expenses', '-', '-', '-',...

Wrapping Functions in Python 3.4 missing required positional argument

I am trying to customize a login_required decorator from the Flask-Login package. I have read the source code and mimicked the syntax. Mine: def login_role_required(f, req_roles=['any']): @wraps(f) def decorated_view(*args, **kwargs): if current_app.login_manager._login_disabled: return f(*args, **kwargs) if not current_user.is_authenticated(): return current_app.login_manager.unauthorized() if req_roles == ['any']: return f(*args, **kwargs) user_roles = current_user.get_roles...

“Initializing” a constant containing a file in python?

I know that initializing variables/constants in python is not necessary, but my professor still wants us to initialize variables for practice. In my program, I have a file to which I assigned a name: infile = open("studentinfo.txt", "r") How would it make sense to initialize the constant "infile"? Can I...

Pylint Error when using metaclass

i try to fix all pylint errors and pylint warnings in a project. but i keep getting an error when i set a metaclass ( here is my example code: #!/usr/bin/env python3 class MyMeta(type): pass class MyObject(object, metaclass=MyMeta): # pylint error here pass the error just says "invalid syntax". i...

multiple iteration of the same list

I have one list of data as follows: from shapely.geometry import box data = [box(1,2,3,4), box(4,5,6,7), box(1,2,3,4)] sublists = [A,B,C] The list 'data' has following sub-lists: A = box(1,2,3,4) B = box(4,5,6,7) C = box(1,2,3,4) I have to check if sub-lists intersect. If intersect they should put in one tuple;...

Docker container http requests limit

I'm new to Docker so, most likely, I'm missing something. I'm running a container with Elasticsearch, using this image. I'm able to setup everyhing correctly. After that I was a using a script developed by a collegue in order to insert some data, basically querying a MySQL database and making...

Python exception for HTTP response codes

I'd like to raise a Python-standard exception when an HTTP response code from querying an API is not 200, but what specific exception should I use? For now I raise an OSError: if response.status_code != 200: raise OSError("Response " + str(response.status_code) + ": " + response.content) I'm aware of the...

How to parse this string?

I have a string like the below string: >>> string = """00 1f 00@ 00c 00e 00N 00> 00E 00O 00F 002 00& 00* 00/ 00) 00 1f 00 1c 00 00 00 17 00\r 00 08 00 03 00 f8 ff ea ff e1 ff e1 ff e0 ff...

The event loop is already running

I have the following 5 files: # -*- coding: utf-8 -*- from PyQt4 import QtCore, QtGui try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def _translate(context, text, disambig): return QtGui.QApplication.translate(context, text, disambig)...

Server initiated requests

I know that http is a request-response protocol, the problem in short is a client makes a request to the server to start a long running process, and i want to inform the client over the progress with a simple json message containg progress info. in http1 i know that...

python 3 error with print function syntax

I have a list of lists with tuples. I want to get the length of a tuple using: item1=(4, 8, 16, 30) list6=[[(4, 8, 16, 29)], [(4, 8, 16, 30)], [(4, 8, 16, 32)]] print("list6.index((4, 8, 16, 29)):",list6.index([item1])) print("len(list6[1]):"), len(list6[1]) Output: list6.index((4, 8, 16, 29)): 1 len(list6[1]): There is no...

Custom HTTP Header or cookies? how custom authentication/authorization helps in CSRF?

If someone can help me understand how a custom HTTP authorization header helps protect CSRF attack. Also correct me if i'm wrong does it prevent replay attacks using fiddler also? Thanks for your help in advance...

Put a QLineEdit() into a QTreeWidgetItem()

Is it possible to put a QLineEdit() into a QTreeWidgetItem() in order to modify the text of the QTreeWidgetItem ? Here is my code def addItemsToTree(self, parent, text, checkable=False, expanded=True): self.item = QTreeWidgetItem(parent, [text]) if checkable: self.item.setCheckState(0, Qt.Unchecked) else: self.item.setFlags(self.item.flags() & ~Qt.ItemIsUserCheckable) self.item.setExpanded(expanded) min = QLineEdit() max = QLineEdit() self.addChildTree(self.item,...

tkinter showerror creating blank tk window

I have a program that needs to display graphical error messages to users. It is a tkinter GUI, so I am using tkinter.messagebox.showerror When I call showerror, it shows the error, but also creates a blank "tk" window, the kind created when an instance of the Tk class is called,...

Python3 after cursor.execute it stopped?

After much trying on python3 (as of still new in this language), the line whereby cursor.execute will prevent the for loop to continue when condition met. However when I comment cursor.execute line, the looping able to continue until the end. How can I made it continue till the last result...

sys.argv in a windows environment

I'm attempting to learn python using the book 'a byte of python'. The code: import sys print('the command line arguments are:') for i in sys.argv: print(i) print('\n\nThe PYTHONPATH is', sys.path, '\n') outputs: the command line arguments are: C:/Users/user/PycharmProjects/helloWorld/ The PYTHONPATH is ['C:\\Users\\user\\PycharmProjects\\helloWorld', 'C:\\Users\\user\\PycharmProjects\\helloWorld', 'C:\\Python34\\', 'C:\\Python34\\DLLs', 'C:\\Python34\\lib', 'C:\\Python34', 'C:\\Python34\\lib\\site-packages']...

AngularJS $http request using forEach inside of Controller

angularjs,http,foreach That's the link for the code. Below I first used the forEach to combine the nicknames with the base link, so I could get the fullLink to make the call for with the $http. But then when I tried to make the call, and post into a empty array,...

subprocess python 3 check_output not same as shell command?

I am trying to use the subprocess module in python but its a bit tricky to get working. Here's my code import sys import os import subprocess import shlex def install_module(dir_path, command): c = shlex.split(command) os.chdir(dir_path) try: p = subprocess.check_output(c, shell=True) except subprocess.CalledProcessError as e: #print('install failed for: ' +...

Return to main fuction in python

Working on Python 3.4.3 Let's say I have created three fuctions: def choosing(mylist=[]): print("We will have to make a list of choices") appending(mylist) done = False while(done == "False"): confirm = input("Is your list complete?[Y/N]") if(confirm == "Y"): print("Yaay! Choices creation complete." "{} choices have been added successfully".format(len(mylist))) done =...

Django runserver not serving some static files

My local testing server for Django v1.8.2 on Windows 8.1 is only serving certain static files. Others are giving a 404 error. - excerpt urlpatterns = [ url(r'^$', views.index) ] + staticfiles_urlpatterns() - excerpt INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'main', 'users' ) STATIC_URL =...

Python3 create files from dictionary

I have a dictionary in a function which is called searchInMyDict(dict) for example. The dictionary included in that function has for key a group name and has for value a list of gene's functions. the dictionary looks like : {"OG_1": ["gene's functionA, gene's functionB, gene's functionC"] "OG_2": ["gene's functionM, gene's...

django-admin startproject not working with python3 on OS X

I have python3 installed with Django 1.8.2 on Mac OS. There is also python 2.7 installed by default with the OS. When trying to run startproject I get - $ django-admin startproject mysite Traceback (most recent call last): File "/usr/local/bin/django-admin", line 7, in <module> from import execute_from_command_line ImportError: No... MVC HTTP Request error with payload,json,,http
I am creating an MVC website with a RESTful API to a SQL database. I have implemented a controller which holds the HTTP commands. One of the commands is a POSTcommand: // POST: api/PoolTests [ResponseType(typeof(PoolTest))] public IHttpActionResult PostPoolTest(PoolTest poolTest) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.PoolTests.Add(poolTest); db.SaveChanges(); return...

Pyqt - Add a QMenuBar to a QMainWindow which is in another class

I have 2 classes : MainWindow() and Menubar(). MainWindow() is a QMainWindow and Menubar is a QMenuBar. I don't know how I can add the menu bar to the main window. With the QToolBar, I can make something like this : self.toolbar = Toolbar() self.addToolBar(self.toolbar) But with the QMenubar, there...

What is a reliable isnumeric() function for python 3?

I am attempting to do what should be very simple and check to see if a value in an Entry field is a valid and real number. The str.isnumeric() method does not account for "-" negative numbers, or "." decimal numbers. I tried writing a function for this: def IsNumeric(self,...

Python file processing?

My assignment was to write a program which extracts the first/last names, birth year, and ID from a file, manipulate that information to create a username and formatted ID, prompt the user for 3 test grades, calculate the average, and finally write all the information to a new file. This...

Why I got so many connection events on Node's HTTP server?

I have a web application using It runs on localhost:8000 on my local machine. In order to find an annoying resource leak in my application, I tried to log out the connection events on my HTTP server: server.on('connection', function(conn) { //log out connection details }); When I open the...

Can I submit a form with google's recaptcha in it from my app?

I'm writing an app which involves letting users to share comments on a website, which has a comment form with Google's reCAPTCHA embeded. I would like to load this page via HTTP and display CAPTCHA within my app, so that user can post comments from my app. Is it easy...

In simple RESTful design, does PATCH imply mapping to CRUD's (ORM's) “update” and PUT to “destroy”+“create” (to replace a resource)?

I'm trying to create a simple REST API and map it to CRUD. I have an ORM (DataMapper) which has methods like create, update and destroy. If I get it right, given a resource {a:'foo',b:'bar',c:'baz'}, performing a PUT {b:'qux'} is supposed to replace the resource and result in the same...

TCL parsing a list of arguments to an external call

Im trying to execute a call to a python script through aldec riviera-pro my call is python $python_app_name $python_app_args However my $python_app_args are passed as a single string and not multiple strings resulting in that the python application only sees it as one argument and its execution fails. I've tried... HTTP Post when auto-incrementing row Id

I am working in with a Web API allowing HTTP Posts to update a mapped SQL database. I want the Id to be automatically increment by one every time a new row is inserted. The table definition is this: CREATE TABLE [dbo].[PoolTests] ( [Id] INT IDENTITY (1, 1), [SiteID]...

index() Method Not Accepting None as Start/Stop

While writing a binary search method for a list I decided to use the builtin index() method on a smaller slice of the list determined via the binary search method. However in certain cases I was getting the error: TypeError: slice indices must be integers or None or have an...

Pass function call as a function argument

Code: def function1(a,b): return a-1,b-1 def function2(c,d): return c+1,d+1 print function1(function2(1,2)) Error: Traceback (most recent call last): File "C:\Users\sony\Desktop\Python\scripts\", line 6, in <module> print function1(function2(1,2)) TypeError: function1() takes exactly 2 arguments (1 given) [Finished in 0.1s with exit code 1] Why the above error? ...

$http headers is not a function - angularjs

I am posting data to Dynamics CRM via SOAP on my PHP server with cURL. After this is done it is giving the entity GUID in the form of a HTTP Response header. When attempting to access this via my angular factory and $http. My header is exposed and is...

Cancel last line iteration on a file

I need to iterate on a file, stop iteration on a condition and then continue parse the file at the same line with another function (That may change so I can't just add content in the previous function). An example file (file.txt) : 1 2 3 4 5 6 7...

writing a tkinter scrollbar for canvas within a class

I've searched around and cannot seem to find an answer for my problem. I am trying to create a working scrollbar for the following code and cannot seem to get it to work. The problem appears to be with the OnFrameConfigure method. I have seen elsewhere that the method should...

Which Http error/status code is the appropriate?

I've carefully read all HTTP error/status codes, still not clear which is the appropriate to return in the following scenario: The request is an Ajax request, so the handling of the error situation depends on the client javascript code, preferably it will give a notification. At server side an unexpected...

“Initializing” variables in python?

Even though initializing variables in python is not necessary, my professor still wants us to do it for practice. I wrote my program and it worked fine, but after I tried to initialize some of the variables I got an error message when I tried to run it. Here is...

nodejs head request isn't triggering events

Here's my code: var http = require('http'); var req = http.request( { host: '', method: 'HEAD', path: '/' }, function(res){ res.on('end',function(){ console.log('Ended'); }); res.on('finish',function(){ console.log('Finished'); }); res.on('close',function(){ console.log('Closed'); }); } ); req.end(); Strange thing about it is that it doesn't print anything. Takes longer than expected and exits. Is this...

How to avoid user to click outside popup Dialog window using Qt and Python?

I created a Dialog window using Qt Creator and Python. I would like that Window stays on the top of my Gui AND avoid users to click outside that Dialog Until this dialog was closed.

How to return value in Meteor.JS from “GET”

I'm writing a meteor method, which should return a Facebook response for on graph api, but has only a callback function to show error/response, so I can't take this data outside, and Method can not return any value. Here's my method code: loadUserFBEvents: function () { var accessToken...

If a block of code creates an error, do x; if not, do y (Python)

In Python, is it possible to test for an error in a block of code, and if one shows up, do something; if not, do something else? The psuedo-code would look like checkError: print("foobar" + 123) succeed: print("The block of code works!") fail: print("The block of code does not work!")...

Installing Python 3 Docker Ubuntu error command 'x86_64-linux-gnu-gcc

I'm trying to create a dockerfile that uses Python 3. FROM ubuntu:14.04 RUN apt-get update RUN apt-get install -y python3 python3-dev python-pip RUN apt-get install -y libxml2-dev libxslt1-dev libpq-dev libjpeg-dev libfreetype6-dev zlib1g-dev RUN cd /var/projects/apps && pip install -r requirements.txt I get the error fatal error: Python.h: No such file...

How to create the get method for the call

I am studying and implementing an api and while following the examples, Here is the example 1 : curl -X POST \ -H "Content-Type: application/json" \ -H "QuickBlox-REST-API-Version: 0.1.0" \ -d '{"application_id": "2", "auth_key": "DtF9cZPqTF8Wy9Q", "timestamp": "1333630580", "nonce": "1340569516", "signature": "13293a5bd2026b957ebbb36c89d9649aae9e5503", "user": {"login": "injoit", "password": "injoit"}}' \ For the...

Integrating PHP Curl

I have the code below which calls up an MySQLi and presents it in XML form in my browser. The next stage is that instead of presenting it in my browser I want to send it to another IP address using PHP Curl. Please can someone help me with the...

Python MVC style GUI Temperature Converter

#The view ( import tkinter import Controller class MyFrame(tkinter.Frame): def __init__(self, controller): tkinter.Frame.__init__(self) self.pack() self.controller = controller #Output Label self.outputLabel = tkinter.Label(self) self.outputLabel["text"] = ("") self.outputLabel.pack({"side":"right"}) #Entry Space self.entrySpace = tkinter.Entry(self) self.entrySpace["text"] = ("") self.entrySpace.pack({"side":"left"}) #two convert buttons self.convertButton=tkinter.Button(self) self.convertButton["text"]= "Fahrenheit to...

What's the fastest way to compare datetime in pandas?

I have two big csv files with different number of rows which I am importing as follows: tdata = pd.read_csv(tfilepath, sep=',', parse_dates=['date_1']) print(tdata.iloc[:, [0,3]]) TBA date_1 0 0 2010-01-04 1 9 2010-01-05 2 0 2010-01-06 3 8 2010-01-07 4 0 2010-01-08 5 0 2010-01-09 pdata = pd.read_csv(pfilepath, sep=',', parse_dates=['date_2']) print(pdata.iloc[:,...

Why does round(5/2) return 2?

Using python 3.4.3, round(5/2) # 2 Shouldn't it return 3? I tried using python 2 and it gave me the correct result round(5.0/2) # 3 How can I achieve a correct rounding of floats?...

How do I make each histogram bin show me the frequency of each action/event/item?

I want to plot a histrogram showing the frequencies of various actions at different intervals. I want to bin the occurence of actions into 10 minute intervals. binwidth = 10*60 #10 minutes times = array([ 1.43431325e+09, 1.43431325e+09, 1.43431329e+09, 1.43431330e+09, 1.43431333e+09, 1.43431334e+09, 1.43431345e+09, 1.43431346e+09, 1.43431346e+09, 1.43431346e+09, 1.43431349e+09, 1.43431350e+09, 1.43431350e+09, 1.43431351e+09, 1.43431354e+09,...

Which LiftResponse class is appropriate for returning an XML based file format?

I have a Lift application which generates a Gephi file on the fly. The Gehpi native format is XML based. The current plan is that the file gets downloaded and opened in Gephi on the client, without being processed/displayed in the browser. I looked through the LiftResponse subclasses and it...