Q_CreationDate
stringlengths
23
23
Title
stringlengths
11
149
Question
stringlengths
25
6.53k
Answer
stringlengths
15
5.1k
Score
float64
-1
1.2
Is_accepted
bool
2 classes
N_answers
int64
1
17
Q_Id
int64
0
6.76k
2014-08-07 12:39:58.260
Using Python pudb debugger with pytest
Before my testing library of choice was unittest. It was working with my favourite debugger - Pudb. Not Pdb!!! To use Pudb with unittest, I paste import pudb;pudb.set_trace() between the lines of code. I then executed python -m unittest my_file_test, where my_file_test is module representation of my_file_test.py file....
Simply by adding the -s flag pytest will not replace stdin and stdout and debugging will be accessible, i.e. pytest -s my_file_test.py will do the trick. In documentation provided by ambi it is also said that previously using explicitly -s was required for regular pdb too, now -s flag is implicitly used with --pdb flag...
1.2
true
1
3,322
2014-08-08 13:54:14.130
Reading BLOB data from Oracle database using python
This is not a question of a code, I need to extract some BLOB data from an Oracle database using python script. My question is what are the steps in dealing with BLOB data and how to read as images, videos and text? Since I have no access to the database itself, is it possible to know the type of BLOBs stored if it is ...
If you have a pure BLOB in the database, as opposed to, say, an ORDImage that happens to be stored in a BLOB under the covers, the BLOB itself has no idea what sort of binary data it contains. Normally, when the table was designed, a column would be added that would store the data type and/or the file name.
0
false
1
3,323
2014-08-09 15:08:05.767
OpenSuse Python-Django Install Issue
I keep receiving the following error message when trying to install Python-Django on my OpenSuse Linux VM: The installation has failed. For more information, see the log file at /var/log/YaST2/y2log. Failure stage was: Adding Repositories Not sure how to add additional Repositories when I am using the opensuse down...
zypper install python-pip pip install virtualenv virtualenv name-env Source name-env/bin/activate (name-env) pip install django==version pip install django
0
false
1
3,324
2014-08-11 02:17:09.503
how to move a number's high 8 bits 7 times in c or python?
For example: EAX = 10101010 00001110 11001010 00100000 I want to move EAX high 8 bits to right 7 times,what can i do in c or in python? In asm : SHR ah,7 The result of EAX is:10101010 00001110 00000001 00100000 And how about SHR ax,7? I have tried ((EAX & 0xff00) >> 8 ) >> 7,but i don't how to add it back to ...
You can store bits from 9th onwards in other variable. Then make those vits 0 in EAX. Then do EAX << 7 and add those bits again to it.
-0.201295
false
1
3,325
2014-08-11 08:57:09.290
How to store base64 information in a MySQL table?
I've done some research, and I don't fully understand what I found. My aim is to, using a udp listener I wrote in python, store data that it receives from an MT4000 telemetry device. This data is received and read in hex, and I want that data to be put into a table, and store it as a string in base64. In terms of stor...
You can storage a base64 string in a TEXT column type, but in my experience I recommend to use LONGTEXT type to avoid truncated errors in big base64 texts.
0
false
2
3,326
2014-08-11 08:57:09.290
How to store base64 information in a MySQL table?
I've done some research, and I don't fully understand what I found. My aim is to, using a udp listener I wrote in python, store data that it receives from an MT4000 telemetry device. This data is received and read in hex, and I want that data to be put into a table, and store it as a string in base64. In terms of stor...
You can just save the base64 string in a TEXT column type. After retrieval just decode this string with base64.decodestring(data) !
1.2
true
2
3,326
2014-08-11 16:22:44.677
Will slicing a list release memory?
My python list named l contains 100 items. If I do, l = l[25:100] Will this release the memory for the first 25 items? If not, how can this be achieved?
Provided there are no other references to l, then memory will be released yes. What happens is: l[25:100] creates a new list object with references to the values from l indices 25 through to 100 (exclusive). l is rebound to now refer the new list object. The reference count for the old list object formerly bound by l ...
1.2
true
2
3,327
2014-08-11 16:22:44.677
Will slicing a list release memory?
My python list named l contains 100 items. If I do, l = l[25:100] Will this release the memory for the first 25 items? If not, how can this be achieved?
There is also an option that doesn't allocate a new list: del l[:25] will remove the first 25 entries from the existing list, shifting the following ones down. Any other references to l will still point to it, but it is altered into a shorter list. Note that reference semantics also apply to each of the items; they ma...
0
false
2
3,327
2014-08-12 10:04:58.693
Multi multiplayer server sockets in python
I am trying to create a multiplayer game for iPhone(cocos2d), which is almost finished, but the multiplayer part is left. I have searched the web for two days now, and can´t find any thing that answers my question. I have created a search room(tcp socket on port 2000) that matches players that searches for a quick matc...
I was thinking I could create a new tcp/udp socket on a new port and let the matched(matched in the search room) players connect to that socket and then have a perfect isolated room for the two to interact with each another. Yes, you can do that. And there shouldn't be anything hard about it at all. You just bind a so...
1.2
true
1
3,328
2014-08-12 13:08:27.877
update file on ssh and link to local computer
I may be being ignorant here, but I have been researching for the past 30 minutes and have not found how to do this. I was uploading a bunch of files to my server, and then, prior to them all finishing, I edited one of those files. How can I update the file on the server to the file on my local computer? Bonus points ...
I don't know your local computer OS, but if it is Linux or OSX, you can consider LFTP. This is an FTP client which supports SFTP://. This client has the "mirror" functionality. With a single command you can mirror your local files against a server. Note: what you need is a reverse mirror. in LFTP this is mirror -r
0
false
2
3,329
2014-08-12 13:08:27.877
update file on ssh and link to local computer
I may be being ignorant here, but I have been researching for the past 30 minutes and have not found how to do this. I was uploading a bunch of files to my server, and then, prior to them all finishing, I edited one of those files. How can I update the file on the server to the file on my local computer? Bonus points ...
Have you considered Dropbox or SVN ?
0
false
2
3,329
2014-08-12 16:52:01.097
How to make trial period for my python application?
I have made a desktop application in kivy and able to make single executable(.app) with pyinstaller. Now I wanted to give it to customers with the trial period of 10 days or so. The problem is how to make a trial version which stop working after 10 days of installation and even if the user un-install and install it ag...
My idea is Make a table in database Use datetime module and put system date in that table as begining date Use timedelta module timedelta(15)( for calculating the date that program needs to be expired here i used 15 day trial in code) and store it in table of database as expiry date Now each time your app start put...
0
false
2
3,330
2014-08-12 16:52:01.097
How to make trial period for my python application?
I have made a desktop application in kivy and able to make single executable(.app) with pyinstaller. Now I wanted to give it to customers with the trial period of 10 days or so. The problem is how to make a trial version which stop working after 10 days of installation and even if the user un-install and install it ag...
You need a web server and a database to get this working. Create a licenses table in your database. Each time a new client pays for your software or asks for a trial, you generate a new long random license, insert it in the licenses table, associate it to the client's email address and send it to the client via email....
1.2
true
2
3,330
2014-08-12 21:03:23.017
How to get shapefile geometry type in PyQGIS?
I'm writing a script that is dependent on knowing the geometry type of the loaded shapefile. but I've looked in the pyqgis cookbook and API and can't figure out how to call it. infact, I have trouble interpreting the API, so any light shed on that subject would be appreciated. Thank you
QgsGeometry has the method wkbType that returns what you want.
0.135221
false
1
3,331
2014-08-13 06:48:09.477
How to launch a python process in Windows SYSTEM account
I am writing a test application in python and to test some particular scenario, I need to launch my python child process in windows SYSTEM account. I can do this by creating exe from my python script and then use that while creating windows service. But this option is not good for me because in future if I change anyth...
Create a service that runs permanently. Arrange for the service to have an IPC communications channel. From your desktop python code, send messages to the service down that IPC channel. These messages specify the action to be taken by the service. The service receives the message and performs the action. That is, ex...
0.201295
false
2
3,332
2014-08-13 06:48:09.477
How to launch a python process in Windows SYSTEM account
I am writing a test application in python and to test some particular scenario, I need to launch my python child process in windows SYSTEM account. I can do this by creating exe from my python script and then use that while creating windows service. But this option is not good for me because in future if I change anyth...
You could also use Windows Task Scheduler, it can run a script under SYSTEM account and its interface is easy (if you do not test too often :-) )
0
false
2
3,332
2014-08-13 13:52:26.470
Python NLTK tokenizing text using already found bigrams
Background: I got a lot of text that has some technical expressions, which are not always standard. I know how to find the bigrams and filter them. Now, I want to use them when tokenizing the sentences. So words that should stay together (according to the calculated bigrams) are kept together. I would like to know if...
The way how topic modelers usually pre-process text with n-grams is they connect them by underscore (say, topic_modeling or white_house). You can do that when identifying big rams themselves. And don't forget to make sure that your tokenizer does not split by underscore (Mallet does if not setting token-regex explicitl...
1.2
true
1
3,333
2014-08-13 14:20:44.987
Using '/' as greater than less than in Python?
I recently got into code golfing and need to save as many characters as possible. I remember seeing someone say to use if a/b: instead of if a<=b:. However, I looked through Python documentation and saw nothing of the sort. I could be remembering this all wrong, but I'm pretty sure I've seen this operator used and reco...
That's just division. And, at least for integers a >= 0 and b > 0, a/b is truthy if a>=b. Because, in that scenario, a/b is a strictly positive integer and bool() applied to a non-zero integer is True. For zero and negative integer arguments, I am sure that you can work out the truthiness of a/b for yourself.
0.995055
false
1
3,334
2014-08-13 22:47:06.127
Is it advisable to write recursive functions in Python
I have written a verilog (logic gates and their connectivity description basically) simulator in python as a part of an experiment. I faced an issue with the stack limit so I did some reading and found that Python does not have a "tail call optimization" feature (i.e. removing stack entries dynamically as recursion pro...
Note: This answer is limited to your topmost question, i.e. "Is it advisable to write recursive functions in Python?". The short answer is no, it's not exactly "advisable". Without tail-call optimization, recursion can get painfully slow in Python given how intensive function calls are on both memory and processor time...
0.058243
false
3
3,335
2014-08-13 22:47:06.127
Is it advisable to write recursive functions in Python
I have written a verilog (logic gates and their connectivity description basically) simulator in python as a part of an experiment. I faced an issue with the stack limit so I did some reading and found that Python does not have a "tail call optimization" feature (i.e. removing stack entries dynamically as recursion pro...
A lot depends on the specific nature of the recursive solution you're trying to implement. Let me give a concrete example. Suppose you want the sum of all values in a list. You can set the recursion up by adding the first value to the sum of the remainder of the list - the recursion should be obvious. However, the ...
0.173164
false
3
3,335
2014-08-13 22:47:06.127
Is it advisable to write recursive functions in Python
I have written a verilog (logic gates and their connectivity description basically) simulator in python as a part of an experiment. I faced an issue with the stack limit so I did some reading and found that Python does not have a "tail call optimization" feature (i.e. removing stack entries dynamically as recursion pro...
I use sys.setrecursionlimit to set the recursion limit to its maximum possible value because I have had issues with large classes/functions hitting the default maximum recursion depth. Setting a large value for the recursion limit should not affect the performance of your script, i.e. it will take the same amount of ti...
0
false
3
3,335
2014-08-14 16:04:56.843
How to prevent user changing URL to see other submission data Django
I'm new to the web development world, to Django, and to applications that require securing the URL from users that change the foo/bar/pk to access other user data. Is there a way to prevent this? Or is there a built-in way to prevent this from happening in Django? E.g.: foo/bar/22 can be changed to foo/bar/14 and expos...
Just check that the object retrieved by the primary key belongs to the requesting user. In the view this would be if some_object.user == request.user: ... This requires that the model representing the object has a reference to the User model.
0.201295
false
1
3,336
2014-08-14 22:09:17.073
What is the equivalent php structure to python's dictionary?
I cannot find how to write empty Python struct/dictionary in PHP. When I wrote "{}" in PHP, it gives me an error. What is the equivalent php programming structure to Python's dictionary?
If you are trying to pass a null value from PHP to a Python dictionary, you need to use an empty object rather than an empty array. You can define a new and empty object like $x = new stdClass();
0
false
1
3,337
2014-08-16 14:53:44.673
django website with gunicorn errror using chrome when login user
i have a strange error with my website which created by django . for the server i use gunicorn and nginx .yes it works well at first,when i use firefox to test my website. i create an account ,login the user ,once i submit the data,the user get login . one day i change to chrome to test my website ,i go to the login pa...
The session information, i.e. which user is logged in, is saved in a cookie, which is send from browser to server with each request. The cookie is set through the server with your login request. For some reason, chrome does not send or save the correct cookie. If you have a current version of each browser, they should ...
0
false
1
3,338
2014-08-17 15:52:30.547
Call system command 'history' in Linux
I am trying to using os.system function to call command 'history' but the stdout just show that 'sh :1 history: not found' Other example i.e. os.system('ls') is works. Can anyone can tell me why 'history' does not work, and how to call 'history' command in Python script.
history is not an executable file, but a built-in bash command. You can't run it with os.system.
-0.386912
false
1
3,339
2014-08-17 16:18:07.717
How would I go about serializing multiple file objects into one file?
I'm currently tasked with the difficult problem of figuring out how to efficiently pack an image and some text within a single file. In doing so, I need to make the file relatively small (it shouldn't be much bigger than the size of the image file alone), and the process of accessing and saving the information should b...
Alex Reynolds idea to use tar archives seems to be a perfect match.
1.2
true
1
3,340
2014-08-18 13:53:14.447
Python OOP: inefficient to put methods in classes?
I usually use classes similarly to how one might use namedtuple (except of course that the attributes are mutable). Moreover, I try to put lengthy functions in classes that won't be instantiated as frequently, to help conserve memory. From a memory point of view, is it inefficient to put functions in classes, if it is...
Methods don't add any weight to an instance of your class. The method itself only exists once and is parameterized in terms of the object on which it operates. That's why you have a self parameter.
1.2
true
2
3,341
2014-08-18 13:53:14.447
Python OOP: inefficient to put methods in classes?
I usually use classes similarly to how one might use namedtuple (except of course that the attributes are mutable). Moreover, I try to put lengthy functions in classes that won't be instantiated as frequently, to help conserve memory. From a memory point of view, is it inefficient to put functions in classes, if it is...
Each object has its own copy of data members whereas the the member functions are shared. The compiler creates one copy of the member functions separate from all objects of the class. All the objects of the class share this one copy. The whole point of OOP is to combine data and functions together. Without OOP, the dat...
0.201295
false
2
3,341
2014-08-18 16:05:00.797
pyramid middleware call to mssql stored procedure - no response
From a pyramid middleware application I'm calling a stored procedure with pymssql. The procedure responds nicely upon the first request I pass through the middleware from the frontend (angularJS). Upon subsequent requests however, I do not get any response at all, not even a timeout. If I then restart the pyramid appl...
The solution was rather trivial. Within one object instance, I was calling two different stored procedures without closing the connection after the first call. That caused a pending request or so in the MSSQL-DB, locking it for further requests.
1.2
true
1
3,342
2014-08-18 19:02:57.403
Django Process Lifetime
When using Django, how long does the Python process used to service requests stay alive? Obviously, a given Python process services an entire request, but is it guaranteed to survive across across requests? The reason I ask is that I perform some expensive computations at when I import certain modules and would like t...
This is not a function of Django at all, but of whatever system is being used to serve Django. Usually that'll be wsgi via something like mod_wsgi or a standalone server like gunicorn, but it might be something completely different like FastCGI or even plain CGI. The point is that all these different systems have their...
1.2
true
1
3,343
2014-08-19 00:12:04.940
How can you edit the brightness of images in PyGame?
I'm trying to make an OpenGL in python/pygame but I don't know how to add shadow. I don't want to make a lot of darker images for my game. Can someone help me?
I am no expert in Python but you could try: Multiply the color of the image by a value like 0.1, 0.2, 0.3 (anything less that 1) which will give you a very dark texture. This would be the easiest method as it involves just reducing the color values of that texture. Or you could try a more complex method such as drawing...
1.2
true
1
3,344
2014-08-19 04:58:23.907
Aptana Studio 3 newproject error with Django
I am having an issue with starting a new project from the command prompt. After I have created a virtual env and activated the enviroment, when I enter in .\Scripts\django-admin.py startproject new_project, a popup window shows up which says "AptanaStudio3 executable launcher was unable to locate its companion shared l...
After some searching, finally figured out that the default program to run the django-admin.py was aptana studio 3, even though the program had supposedly been uninstalled completely from my system. I changed the default program to be the python console launcher and now it works fine. There goes 2 hours down the drain..
0
false
1
3,345
2014-08-19 09:52:52.337
Python CSV module - how does it avoid delimiter issues?
I am using python's CSV module to output a series of parsed text documents with meta data. I am using the csv.writer module without specifying a special delimiter, so I am assuming it is delimited using commas. There are many commas in the text as well as in the meta data, so I was expecting there to be way more column...
You shall inspect the real content of CSV file you have created and you will see, that there are ways to enclose text in quotes. This allows distinction between delimiter and a character inside text value. Check csv module documentation, it explains these details too.
0.201295
false
1
3,346
2014-08-19 20:53:03.317
In Python, how do I tie an on-disk JSON file to an in-process dictionary?
In perl there was this idea of the tie operator, where writing to or modifying a variable can run arbitrary code (such as updating some underlying Berkeley database file). I'm quite sure there is this concept of overloading in python too. I'm interested to know what the most idiomatic way is to basically consider a lo...
If concurrency is not required, maybe consider writing 2 functions to read and write the data to a shelf file? Our is the idea to have the dictionary" aware" of changes to update the file without this kind of thing?
0
false
2
3,347
2014-08-19 20:53:03.317
In Python, how do I tie an on-disk JSON file to an in-process dictionary?
In perl there was this idea of the tie operator, where writing to or modifying a variable can run arbitrary code (such as updating some underlying Berkeley database file). I'm quite sure there is this concept of overloading in python too. I'm interested to know what the most idiomatic way is to basically consider a lo...
This is a developpement from aspect_mkn8rd' answer taking into account Gerrat's comments, but it is too long for a true comment. You will need 2 special container classes emulating a list and a dictionnary. In both, you add a pointer to a top-level object and override the following methods : __setitem__(self, key, va...
0.135221
false
2
3,347
2014-08-20 02:22:37.870
can I use python to paste commands into LX terminal?
okay, So for a school project I'm using raspberry pi to make a device that basically holds both the functions of an ocr and a tts. I heard that I need to use Google's tesseract through a terminal but I am not willing to rewrite the commands each time I want to use it. so i was wondering if i could either: A: Use python...
There are ways to do what you asked, but I think you lack some research of your own, as some of these answers are very "googlable". You can print commands to LX terminal with python using "sys.stdout.write()" For the boot question: 1 - sudo raspi-config 2 - change the Enable Boot to Desktop to Console 3 - there is more...
0
false
1
3,348
2014-08-20 11:07:50.743
How to call methods of class tornado.httpserver.HTTPserver?
I am learning the web framework Tornado. During the study of this framework, I found the class tornado.httpserver.HTTPserver. I know how to create a constructor of this class and create instance tornado.httpserver.HTTPserver in main() function. But this class tornado.httpserver.HTTPserver has 4 methods. I have not fo...
These methods are used internally; you shouldn't call them yourself.
1.2
true
1
3,349
2014-08-21 00:32:37.210
Elegant Solution to an OOP Issue involving type-changing in python
I run into an OOP problem when coding something in python that I don't know how to address in an elegant solution. I have a class that represents the equation of a line (y = mx + b) based on the m and b parameters, called Line. Vertical lines have infinite slope, and have equation x = c, so there is another class Verti...
Geometric objects that have a fixed boundary/end-points can be translated and rotated in place. But for a line, unless you talk about a line from point A to point B with a fixed length, you are looking at both end-points either being at infinity or -infinity (y = mx + c). Division using infinity or -infinity is not sim...
0
false
1
3,350
2014-08-21 06:23:51.930
How to connect to kivy-remote-shell?
This seems to be a dumb question, but how do I ssh into the kivy-remote-shell? I'm trying to use buildozer and seem to be able to get the application built and deployed with the command, buildozer -v android debug deploy run, which ends with the application being pushed, and displayed on my android phone, connected via...
Don't know you found the answer or not. But what i have understood is that you are trying to connect android device from Ubuntu. If I am right then (go on reading) you are following wrong steps. First :- Your Ubuntu does not have ssh server by default so you get this error message. Second :- You are using 127.0.0.1 add...
0
false
3
3,351
2014-08-21 06:23:51.930
How to connect to kivy-remote-shell?
This seems to be a dumb question, but how do I ssh into the kivy-remote-shell? I'm trying to use buildozer and seem to be able to get the application built and deployed with the command, buildozer -v android debug deploy run, which ends with the application being pushed, and displayed on my android phone, connected via...
When the app is running, the GUI will tell you what IP address and port to connect to.
0.265586
false
3
3,351
2014-08-21 06:23:51.930
How to connect to kivy-remote-shell?
This seems to be a dumb question, but how do I ssh into the kivy-remote-shell? I'm trying to use buildozer and seem to be able to get the application built and deployed with the command, buildozer -v android debug deploy run, which ends with the application being pushed, and displayed on my android phone, connected via...
127.0.0.1 This indicates something has gone wrong - 127.0.0.1 is a standard loopback address that simply refers to localhost, i.e. it's trying to ssh into your current computer. If this is the ip address suggested by kivy-remote-shell then there must be some other problem, though I don't know what - does it work on an...
0.135221
false
3
3,351
2014-08-21 09:29:58.523
Customized Execution status in Robot Framework
In Robot Framework, the execution status for each test case can be either PASS or FAIL. But I have a specific requirement to mark few tests as NOT EXECUTED when it fails due to dependencies. I'm not sure on how to achieve this. I need expert's advise for me to move ahead.
Actually, you can SET TAG to run whatever keyword you like (for sanity testing, regression testing...) Just go to your test script configuration and set tags And whenever you want to run, just go to Run tab and select check-box Only run tests with these tags / Skip tests with these tags And click Start button :) Robot ...
-0.081452
false
1
3,352
2014-08-22 05:17:32.777
how to display matplotlib plots on local machine?
I am running ipython remotely on a remote server. I access it using serveraddress:8888/ etc to write code for my notebooks. When I use matplotlib of course the plots are inline. Is there any way to remotely send data so that plot window opens up? I want the whole interactive environment on matplotlib on my local machin...
There are a few possibilities If your remote machine is somehow unixish, you may use the X Windows (then your session is on the remote machine and display on the local machine) mpld3 bokeh and iPython notebook nbagg backend of matplotlib.¨ Alternative #1 requires you to have an X server on your machine and a connecti...
1.2
true
2
3,353
2014-08-22 05:17:32.777
how to display matplotlib plots on local machine?
I am running ipython remotely on a remote server. I access it using serveraddress:8888/ etc to write code for my notebooks. When I use matplotlib of course the plots are inline. Is there any way to remotely send data so that plot window opens up? I want the whole interactive environment on matplotlib on my local machin...
You want to get the regular (zoomable) plot window, right? I think you can not do it in the same kernel as, unfortunately, you can't switch from inline to qt and such because the backend has already been chosen: your calls to matplotlib.use() are always before pylab.
0
false
2
3,353
2014-08-22 06:22:10.197
Running an .exe script from a VB script by passing arguments during runtime
I have converted a python script to .exe file. I just want to run the exe file from a VB script. Now the problem is that the python script accepts arguments during run-time (e.g.: serial port number, baud rate, etc.) and I cannot do the same with the .exe file. Can someone help me how to proceed?
If you don't have the source to the python exe convertor and if the arguments don't need to change on each execution, you could probably open the exe in a debugger like ollydbg and search for shellexecute or createprocess and then create a string in a code cave and use that for the arguments. I think that's your only o...
1.2
true
1
3,354
2014-08-23 06:55:49.593
Making unique screen transitions - kivy
I have two screens and want to change the SlideTransition from my second to first screen to direction: 'right' while keeping the first to second transition the default. The docs only show how to change the transition for every transition. How would I make a transition unique to one screen, done in the kv file? Note: I ...
There isn't a property that lets you simply do this - the transition is a property of the screenmanager, not of the screen. You could add your own screen change method for the screenmanager that knows about the screen names and internally sets the transition.
1.2
true
1
3,355
2014-08-24 03:09:38.563
Issues decoding a Python 3 Bytes object based on MIDI
I am dealing with the following string of bytes in Python 3. b'\xf9', b'\x02', b'\x03', b'\xf0', b'y', b'\x02', b'\x03', b'S', b'\x00', b't', b'\x00', b'a' This is a very confusing bunch of bytes for me because it is coming from a microcontroller which is emitting information according to the MIDI protocol. My first q...
They return the same thing because b'\x53' == b'S'. It's the same of other characters in the ASCII table as they're represented by the same bytes. You're getting a UnicodeDecodeError because you seem to be using a wrong encoding. If I run b'\xf9'.decode('iso-8859-1') I get ù so it's possible that the encoding is ISO-88...
1.2
true
1
3,356
2014-08-25 15:35:23.137
Writing a line to CMD in python
I am very new to Python and I have been trying to find a way to write in cmd with python. I tried os.system and subprocess too. But I am not sure how to use subprocess. While using os.system(), I got an error saying that the file specified cannot be found. This is what I am trying to write in cmd os.system('cd '+path+'...
Each call to os.system is a separate instance of the shell. The cd you issued only had effect in the first instance of the shell. The second call to os.system was a new shell instance that started in the Python program's current working directory, which was not affected by the first cd invocation. Some ways to do wha...
1.2
true
1
3,357
2014-08-25 22:40:10.283
Display a contantly updated text file in a web user interface using Python flask framework
In my project workflow, i am invoking a sh script from a python script file. I am planning to introduce a web user interface for this, hence opted for flask framework. I am yet to figure out how to display the terminal output of the shell script invoked by my python script in a component like text area or label. This f...
The one way I can think of doing this is to refresh the page. So, you could set the page to refresh itself every X seconds. You would hope that the file you are reading is not large though, or it will impact performance. Better to have the output in memory.
0
false
1
3,358
2014-08-28 13:33:34.857
Access Django app from other computers
I am developing a web application on my local computer in Django. Now I want my webapp to be accessible to other computers on my network. We have a common network drive "F:/". Should I place my files on this drive or can I just write something like "python manage.py runserver test_my_app:8000" in the command prompt to ...
Just add your own IP Address to ALLOWED_HOSTS ALLOWED_HOSTS = ['192.168.1.50', '127.0.0.1', 'localhost'] and run your server python manage.py runserver 192.168.1.50:8000 and access your own server to other computer in your network
0.565852
false
3
3,359
2014-08-28 13:33:34.857
Access Django app from other computers
I am developing a web application on my local computer in Django. Now I want my webapp to be accessible to other computers on my network. We have a common network drive "F:/". Should I place my files on this drive or can I just write something like "python manage.py runserver test_my_app:8000" in the command prompt to ...
very simple, first you need to add ip to allowed host, ALLOWED_HOST =['*'] 2. then execute python manage.py runserver 0.0.0.0:8000 now you can access the local project on different system in the same network
0
false
3
3,359
2014-08-28 13:33:34.857
Access Django app from other computers
I am developing a web application on my local computer in Django. Now I want my webapp to be accessible to other computers on my network. We have a common network drive "F:/". Should I place my files on this drive or can I just write something like "python manage.py runserver test_my_app:8000" in the command prompt to ...
Run the application with IP address then access it in other machines. python manage.py runserver 192.168.56.22:1234 Both machines should be in same network, then only this will work.
0.336246
false
3
3,359
2014-08-28 15:00:47.813
What are the steps to create or generate an Excel sheet in OpenERP?
I need to know, what are the steps to generate an Excel sheet in OpenERP? Or put it this way, I want to generate an Excel sheet for data that I have retrieved from different tables through queries with a function that I call from a button on wizard. Now I want when I click on the button an Excel sheet should be generat...
You can do it easily with python library called XlsxWriter. Just download it and add in openerp Server, look for XlsxWriter Documentation , plus there are also other python libraries for generating Xlsx reports.
1.2
true
1
3,360
2014-08-28 20:43:41.957
Pyinstaller scrapy error:
After installing all dependencies for scrapy on windows 32bit. I've tried to build an executable from my scrapy spider. Spider script "runspider.py" works ok when running as "python runspider.py" Building executable "pyinstaller --onefile runspider.py": C:\Users\username\Documents\scrapyexe>pyinstaller --onefile ru...
You need to create a scrapy folder under the same directory as runspider.exe (the exe file generated by pyinstaller). Then copy the "VERSION" and "mime.types" files(default path: %USERPROFILE%\AppData\Local\Programs\Python\Python37\Lib\site-packages\scrapy) to the scrapy you just created in the scrappy folder you creat...
0
false
1
3,361
2014-09-01 10:53:49.770
How to set IAM role with MrJob 0.4.2 on EMR
I'm trying to set an IAM role to my EMR cluster with mrjob 0.4.2. I saw that there is a new option in 0.4.3 to do this, but it is still in development and I prefer to use the stable version instead. Any idea on how to do this? I have tried to create the cluster using Amazon's console and then run the bootstrap+step act...
Well, after many searches, it seems there is no such option
1.2
true
1
3,362
2014-09-02 13:51:47.310
Error installing Pygame / Python 3.4.1
I'm trying to install Pygame and it returns me the following error "Python version 3.4 required which was not found in the registry". However I already have the Python 3.4.1 installed on my system. Does anyone know how to solve that problem? I've been using Windows 8.1 Thanks in advance.
Tips I can provide: Add Python to your Path file in the Advanced settings of your Environmental Variables (just search for it in the control panel) Something may have gone wrong with the download of Python, so re-install it. Also don't download the 64-bit version, just download the 32-bit version from the main pygame ...
0
false
2
3,363
2014-09-02 13:51:47.310
Error installing Pygame / Python 3.4.1
I'm trying to install Pygame and it returns me the following error "Python version 3.4 required which was not found in the registry". However I already have the Python 3.4.1 installed on my system. Does anyone know how to solve that problem? I've been using Windows 8.1 Thanks in advance.
Are you using a 64-bit operating system? Try using the 32-bit installer.
0.545705
false
2
3,363
2014-09-03 16:04:56.840
Start Tkinter in background
Comically enough, I was really annoyed when tkinter windows opened in the background on Mac. However, now I am on Linux, and I want tkinter to open in background. I don't know how to do this, and when I google how to do it, all I can find are a lot of angry Mac users who can't get tkinter to open in the foreground. I s...
I am using Linux Mint. In order to make a program not show up in the foreground (i.e. be hidden behind all of the other windows), one should use root.lower() as aforementioned in the comments. However, please note (and this seems to happen on multiple platforms) that root.lower() will not change the focus of the window...
1.2
true
1
3,364
2014-09-05 07:58:00.423
Emacs: how to make abbrevs work in python comments?
I'm trying to use abbrev-mode in python-mode. Abbrevs work fine in python code but doesn't work in python comments. How can I make them work in python comments too? Thanks.
IIRC this was a bug in python.el and has been fixed in more recent versions. Not sure if the fix is in 24.3 or in 24.4. If it's still in the 24.4 pretest, please report it as a bug.
0
false
1
3,365
2014-09-06 10:28:20.077
How to access system display memory / frame buffer in a Java program?
I am trying to create my own VNC client and would like to know how to directly access system display memory on Linux? So that I can send it over a Socket or store it in a file locally. I have researched a bit and found that one way to achieve this is to capture the screen at a high frame rate (screenshot), convert it i...
directly access system display memory on Linux You can't. Linux is a memory protected virtual address space operating system. Ohh, the kernel gives you access to the graphics memory through some node in /dev but that's not how you normally implement this kind of thing. Also in Linux you're normally running a display s...
1.2
true
1
3,366
2014-09-07 17:19:57.633
Python: Turtle size in pixels
I have got a problem. I want to get the pixeled size of my turtle in Python, but how do I get it?
I know exactly what you mean, shapesize does not equal the width in pixels and it had me buggered for a day or 2. I ended up changing the turtle shape to a square and simply using print screen in windows to take a snap shot of the canvas with the square turtle in the middle, then took that print screen into Photoshop t...
0.101688
false
1
3,367
2014-09-08 16:03:10.293
How the user of my Django app can create "customized" tasks?
I am new to Celery and I can't figure out at all how I can do what I need. I have seen how to create tasks by myself and change Django's file settings.py in order schedule it. But I want to allow users to create "customized" tasks. I have a Django application that is supposed to give the user the opportunity to create ...
As you know how to create & execute tasks, it's very easy to allow customers to create tasks. You can create a simple form to get required information from the user. You can also have a profile page or some page where you can show user preferences. The above form helps to get data(like how frequently he needs to receiv...
0
false
1
3,368
2014-09-09 08:23:17.253
passing user information from php to django
I am building a web app in django and I want to integrate it with the php web app that my friend has build. Php web app is like forum where students can ask question to the teachers. For this they have to log in. And I am making a app in django that displays a list of colleges and every college has information about t...
You must use one of these possibilities: Your friend gives you direct access (even only read access) to his database and you represent everything as Django models or use raw SQL. The problem with that approach is that you have a very high-coupling between the two systems. If he changes his table or scheme structure fo...
1.2
true
1
3,369
2014-09-09 15:23:40.617
Django Extend admin index
I wish to make some modifications to the Django admin interface (specifically, remove the "change" link, while leaving the Model name as a link to the page for changes to the instances). I can achieve this by copying and pasting index.html from the admin application, and making the modifications to the template, but I ...
Worked it out - I set admin.site.index_template = "my_index.html" in admin.py, and then the my_index template can inherit from admin/index.html without a name clash.
1.2
true
1
3,370
2014-09-09 16:21:37.390
RabbitMQ message lost
I use Python api to insert message into the RabbitMQ,and then use go api to get message from the RabbitMQ. Key 1: RabbitMQ ACK is set false because of performance. I insert into RabbitMQ about over 100,000,000 message by python api,but when I use go api to get message,I find the insert number of message isn’t equal to...
In order for you to test that all of your messages are published you may do it this way: Stop consumer. Enable acknowledgements in publisher. In python you can do it by adding extra line to your code: channel.confirm_delivery(). This will basically return a boolean if message was published. Optionally you may want to ...
1.2
true
1
3,371
2014-09-10 16:21:20.697
Django session id security tips?
I'm currently developing a site with Python + Django and making the login I started using the request.session[""] variables for the session the user was currently in, and i recently realized that when i do that it generates a cookie with the "sessionid" in it with a value every time the user logs in, something like thi...
Sadly, there is no best way you can prevent this from what I know but you can send the owner of an account an email and set some type of 2fa.
0
false
1
3,372
2014-09-10 23:44:00.040
System Call in Python via MINGW32 on Windows
I am trying to figure out a way to call wget from my python script on a windows machine. I have wget installed under /bin on the machine. Making a call using the subprocess or os modules seems to raise errors no matter what I try. I'm assuming this is related to the fact that I need to route my python system call th...
There's no such thing as under "MinGW". You probably mean under MSYS, a Unix emulation environment for Windows. MSYS makes things look like Unix, but you're still running everything under Windows. In particular MSYS maps /bin to the drive and directory where you install MSYS. If you installed MSYS to C:\MSYS then your ...
1.2
true
1
3,373
2014-09-11 16:09:18.093
How to find out from where is a Python script called?
I need to test whether several .py scripts (all part of a much bigger program) work after updating python. The only thing I have is their path. Is there any intelligent way how to find out from which other scripts are these called? Brute-forece grepping wasn't as good aas I expected.
I combined two things: ran automated tests with the old and new version of pythona nd compared results used snakefood to track the dependencies and ran the parent scripts Thanks for the os.walk and os.getppid suggestion, however, I didn't want to write/use any additional code.
1.2
true
1
3,374
2014-09-11 21:48:04.883
Is it possible to implement webhooks on regular clients?
I am trying to create a python application that can continuously receive data from a webserver. This python application will be running on multiple personal computers, and whenever new data is available it will receive it. I realize that I can do this either by long polling or web sockets, but the problem is that somet...
There is no way to send data to the client without having some kind of connection, e.g. either websockets or (long) polling done by the client. While it would be possible in theory to open a listener socket on the client and let the web server could connect to and sent the data to this socket, this will not work in rea...
0
false
1
3,375
2014-09-12 03:56:07.527
Exporting cpython AST symbols on Windows
I'm writing a C application that makes use of Python's AST API to transform Python code expressions before emitting bytecode. I've been a longtime POSIX developer (currently OS X), but I wish learn how to port my projects to Windows as well. I'm using the static libraries (.lib) generated by build.bat in Python's PCBui...
OK, I figured it out I was using VS 2013 while Python's build system was designed for VS 2010. I ended up retargeting everything for 2013 (including a small modification to the tix makefile) and it compiled with all non-static symbols (AST and all) as expected. Python.org's official pre-built Windows libraries still se...
0
false
1
3,376
2014-09-12 17:59:40.937
Python programs communicating
I have a (probably) simple question that the internet seems to be of no help with. I would like to make several python programs interact within another python program and have no idea how to get them to put input into each other. My eventual idea is to (as a proof of concept) have one program act as the environment and...
You have a lot of choices for exhanging messages between programs or components: You can write output files that other programs can read and act on. You'd like to see if the consumer could watch a directory for a file and react when it arrived. You could make them distributed components that exchanged messages via so...
0
false
1
3,377
2014-09-13 06:59:41.697
PyDev Interactive Console Issue
So I installed PyDev in Eclipse and started testing it and I have come to an issue. While using IDLE to run Python I could, for example, create a file, set a variable x = 10 and then make IDLE run said file. I would then be able to ask python for x and it would give me 10. I don't know how to do that in PyDev. I...
Hmmm, I am not familiar with the IDE IDLE, nor do I typically run a file via the console, but maybe I understand your question. The core answer is you need a breakpoint so that execution does not terminate and therefore x=10 is resident in memory. If the breakpoint is set post x=10, then when you reach the breakpoint ...
1.2
true
1
3,378
2014-09-14 22:39:55.990
Sphinx PDF output is bad. How do I chase down the cause?
My Sphinx input is six rst files and a bunch of PNGs and JPGs. Sphinx generates the correct HTML, but when I make pdf I get an output file that comes up blank in Adobe Reader (and comes up at over 5000%!) and does not display at all in Windows Explorer. The problem goes away if I remove various input files or if I edi...
We had a similar problem: bad pdf output on project with a lot of chapters and images. We solved disabling the break page: in the conf.py, set the pdf_break_level value at 0.
0
false
1
3,379
2014-09-15 16:09:19.180
Python pyc files created with root as owner
I have a python program, stored on Dropbox, which runs via cron on a couple of different machines. For some reason, recently one of the .pyc files is being created with root as the owner, which means that Dropbox doesn't have permission to sync it anymore. Why would it do that, and how do I change it?
That would happen if you're running the python program as root (which would happen if you're using root's crontab). To fix it, just remove it with sudo rm /path/to/file.pyc, and make sure to run the program as your user next time. If you want to keep using root's crontab, you could use su youruser -c yourprogram, but t...
0.386912
false
1
3,380
2014-09-15 22:52:14.217
How to use os module to save a jpeg to a cretin path- Using kivy screenshot()
Is there a way to use the OS module in python to save a jpeg created by the screenshot() function in Kivy? I am on Android so I want to find a way to make it so that the screenshot() gets saved in /sdcard/Pictures. If I don't have to use the OS module, how would I do it? Please use examples and add code snippets that o...
I want to find a way to make it so that the screenshot() gets saved in /sdcard/Pictures. The argument to screenshot is the filepath to save at, just write Window.screenshot('/sdcard/Pictures').
1.2
true
1
3,381
2014-09-16 14:54:02.827
Networkx appends 'u' before node names after reading in from an edge list. How to get rid?
I created a graph in Networkx by importing edge information in through nx.read_edgelist(). This all works fine and the graph loads. The problem is when I print the neighbors of a node, I get the following for example... [u'own', u'record', u'spending', u'companies', u'back', u'shares', u'their', u'amounts', u'are', u...
You don't need to get rid of them, they don't do anything other than specify the encoding type. This can be helpful sometimes, but I can't think of a time when it isn't helpful.
0.135221
false
1
3,382
2014-09-17 07:01:45.037
APScheduler store job in custom database of mongodb
I want to store the job in mongodb using python and it should schedule on specific time. I did googling and found APScheduler will do. i downloaded the code and tried to run the code. It's schedule the job correctly and run it, but it store the job in apscheduler database of mongodb, i want to store the job in my own ...
Simply give the mongodb jobstore a different "database" argument. It seems like the API documentation for this job store was not included in what is available on ReadTheDocs, but you can inspect the source and see how it works.
0.386912
false
1
3,383
2014-09-17 13:05:59.280
How can I get Python to recognize the SPSSClient Module?
I originally installed Canopy to use Python, but it would not recognize the SPSS modules, so I removed canopy, re-downloaded python2.7, and changed my PATH to ;C:\Python27. In SPSS, I changed the default python file directory to C:\Python27. Python still will not import the SPSS modules. I have a copy of SPSS 22, so py...
Glad that is solved. The 32/64-bit issue has been a regular confusion for Statistics users.
0.201295
false
2
3,384
2014-09-17 13:05:59.280
How can I get Python to recognize the SPSSClient Module?
I originally installed Canopy to use Python, but it would not recognize the SPSS modules, so I removed canopy, re-downloaded python2.7, and changed my PATH to ;C:\Python27. In SPSS, I changed the default python file directory to C:\Python27. Python still will not import the SPSS modules. I have a copy of SPSS 22, so py...
I figured this out only with some help from a friend who had a similar issue. I had downloaded python from python.org, without realizing it was 32 bit. All of the SPSS modules are 64 bit! I downloaded the correct version of python, and then copied the spss modules from my spss install (inside the python folder within s...
1.2
true
2
3,384
2014-09-18 00:24:41.657
In Python, how can I run a module that's not in my path?
I'm using PyCharm, and in the shell, I can't run a file that isn't in the current directory. I know how to change directories in the terminal. But I can't run files from other folders. How can I fix this? Using Mac 2.7.8. Thanks!
There are multiple ways to solve this. In PyCharm go to Run/Edit Configurations and add the environment variable PYTHONPATH to $PYTHONPATH: and hit apply. The problem with this approach is that the imports will still be unresolved but the code will run fine as python knows where to find your modules at run time. If y...
0.135221
false
1
3,385
2014-09-19 00:42:38.183
python idle how to create username?
Write a function called getUsername which takes two input parameters, firstname (string) and surname (string), and both returns and prints a username made up of the first character of the firstname and the first four characters of the surname. Assume that the given parameters always have at least four characters.
This is how you build the string: firstname[0] + surname[:4]
0
false
1
3,386
2014-09-19 14:02:49.130
Command line interface application with background process
I'm new to python. I'm trying to write an application with command line interface. The main application is communicating with server using tcp protocol. I want it to work in the background so I won't have to connect with the server every time I use interface. What is a proper approach to such a problem? I don't want t...
If you put something in the background, then it's no longer connected to the current shell (or the terminal). So you would need the background process to open a socket so the command line part could send it the command. In the end, there is no way around creating a new connection to the server every time you start the ...
0
false
1
3,387
2014-09-19 22:18:33.253
Redhat Python 2.7.6 installation on virtualenv
in what order should I install things? My goal is to have python 2.7.6 running on a virtualenv for a project for work. I am working on a Virtual Box machine in CentOS 6.5. What folders should I be operating in to install things? I have never used linux before today, and was just kind of thrust into this task of gettin...
With Linux you don't need to worry about where to install files, the OS takes care of that for you. Google CentOS Yum and read the Yum docs on how to install everything. You probably already have Python 2.7 installed, to check just open the terminal CTRL + ALT + T, and type python. This will start the python interpr...
1.2
true
1
3,388
2014-09-21 23:22:52.193
How to use the index method efficiently
I have recently started learning Python, and I received a question: "Write a Python program that asks the user to enter full name in the following format: LastName, FirstName MiddleName (for Example: "Hun, Attila The”). The input will have a single space after the comma and only a single space between the first name an...
Instead of using index, use split and split on the various separators. E.g., full_name.split(', ')[0] == 'Hun', full_name.split(', ')[1] == 'Attila', and full_name.split(' ')[-1] == 'The'. You can then easily recombine them with string formatting or simple concatenation.
1.2
true
1
3,389
2014-09-22 01:33:11.070
Display the number of duplicate requests filtered in the post-crawler stats
One of the Scrapy spiders (version 0.21) I'm running isn't pulling all the items I'm trying to scrape. The stats show that 283 items were pulled, but I'm expecting well above 300 here. I suspect that some of the links on the site are duplicates, as the logs show the first duplicate request, but I'd like to know exactly...
You can maintain a list of urls that u have crawled , whenever you came across a url that is already in the list you can log it and increment a counter.
0
false
1
3,390
2014-09-23 17:49:35.040
Truncating values before the decimal point
I am trying to make a calculator that converts cms into yards, feet, and inches. Example: 127.5 cm is 1 yard, 1 inch, etc. But I am just wondering how I am able to retain the value after the decimal place, is there a way to truncate the number before the decimal place. So if the user inputs a value that results into 3....
What's wrong with the good old-fashioned value - int(value)?
0.135221
false
1
3,391
2014-09-24 23:41:04.237
how to change file extensions in windows 8? i tried and it will not recognize the change
How do I change file extensions in windows 8? I tried and my system will not recognize the change. I tried changing from .txt to .py for python so i can use in IDLE.
I created a file called myfile.txt. It showed up in Explorer as myfile.txt. If you just see myfile (no extension), then go to Folder Options, Advanced, and uncheck "Hide extensions for known file types". I Right-clicked myfile.txt, selected Rename, and Windows selected just "myfile", not ".txt". I changed the selection...
0.386912
false
1
3,392
2014-09-26 00:53:04.860
Running Python GUI apps on C9.io
Does anyone know if it is possible to run python-gui apps, like wxPython, on a c9.io remote server? I have my home server set up with c9 via SSH, and no issues logging in and running apps in the terminal on the VM. However, when I try to run GUI apps, I get the following error message. Unable to access the X Display, ...
I don't know if Cloud9 supports it but normally to run a remote GUI application you would have ssh forward the X11 communication over the ssh connection via a tunnel. So basically the application is running on the remote system and it is communicating with a local X11 server which provides you with the display and han...
0.386912
false
1
3,393
2014-09-26 08:04:41.853
Get free space of a directory in linux
I have a question. In my c# application I need to get the free space of a directory. According to my research, GetdiskfreespaceEx is proper and it works for me in my windows xp. Now I'm wondering if it works the same in a linux system. Since I wrote my c# program according to a python one, and for this function the dev...
For Linux you will find Statvfs in Mono.Unix.Native, in the Mono.Posix assembly.
0
false
1
3,394
2014-09-26 22:36:11.393
Python How to force user input to be to 2dp
Hi I am a beginner on Python and was wondering how you can make a user input a number that contains two decimal places or less
Check out the wxPython demo, I would probably use the wx.lib.masked.numctrl for that.
0
false
1
3,395
2014-09-27 00:16:50.530
Share connection to postgres db across processes in Python
I have a Python script running as a daemon. At startup, it spawns 5 processes, each of which connects to a Postgres database. Now, in order to reduce the number of DB connections (which will eventually become really large), I am trying to find a way of sharing a single connection across multiple processes. And for this...
You can't sanely share a DB connection across processes like that. You can sort-of share a connection between threads, but only if you make sure the connection is only used by one thread at a time. That won't work between processes because there's client-side state for the connection stored in the client's address spac...
1.2
true
1
3,396
2014-09-28 01:13:21.797
How to post a form to django site, securely and from another site
I have a django app which need to receive post requests from another site using html+javascript. For example i have mydjangosite.com and smallhtmlsite.com What i want is : user visit smallhtmlsite.com and fill a form, then he pushing submit button and mydjangosite.com receive request and create objects(form saving mo...
I have a django app which need to receive post requests from another site using html+javascript. You don't have to ! You can build an API instead ;) You create an API call - small site calls the API of main site. In that situation, the form is handled by a view in small site and the API is called via the server. Che...
0.386912
false
1
3,397
2014-09-29 14:49:35.397
how do i configure python/flask for public access with windows firewall
We have developed an app in python and are using flask to expose its api via http requests. all this on WINDOWS - Everything works ok and we have tested in-house with no problems and we are now trying to use the app in the real world - we have gotten our IT dept to give us a public facing ip/port address (forwarded ...
When running as a service the program running the service is not python.exe but rather pythonservice.exe. You will have to add that to the allowed programs in the Windows Firewall Setup. In my case it is located under C:\Python33\Lib\site-packages\win32\pythonservice.exe.
0.201295
false
1
3,398
2014-09-29 20:19:26.617
create database by load a csv files using the header as columnnames (and add a column that has the filename as a name)
I have CSV files that I want to make database tables from in mysql. I've searched all over and can't find anything on how to use the header as the column names for the table. I suppose this must be possible. In other words, when creating a new table in MySQL do you really have to define all the columns, their names, th...
The csv module can easily give you the column names from the first line, and then the values from the other ones. The hard part will be do guess the correct column types. When you load a csv file into an Excel worksheet, you only have few types : numeric, string, date. In a database like MySQL, you can define the size...
1.2
true
1
3,399
2014-09-29 21:52:31.460
Insert json log files in rethinkdb?
I have a log file by the name log.json. A simple insert in rethinkdb works perfectly. Now this json file get updated every second, how to make sure that the rethinkdb gets the new data automatically, is there a way to achieve this, or i have to simply use the API and insert into db as well as log in a file if i want to...
The process that appends new entries in your json file should probably run query to insert the same entries in RethinkDB. Or you can have a cron job that get the last entry saved from rethinkdb read your json file for new entries insert new entries
1.2
true
1
3,400
2014-09-30 05:33:03.863
Removing padding from UDP packets in python (Linux)
I am trying to remove null padding from UDP packets sent from a Linux computer. Currently it pads the size of the packet to 60 bytes. I am constructing a raw socket using AF_PACKET and SOCK_RAW. I created everything from the ethernet frame header, ip header (in which I specify a packet size of less than 60) and the udp...
This is pretty much impossible without playing around with the Linux drivers. This isn't the best answer but it should guide anyone else looking to do this in the right direction.3 Type sudo ethtool -d eth0 to see if your driver has pad short packets enabled.
1.2
true
1
3,401
2014-09-30 08:39:13.763
How to set font size using TextItem.setText() in PyQtGraph?
When creating a TextItem to be added to a plotItem in PyQtGraph, I know it is possible to format the text using html code, however I was wondering how to format the text (i.e. change font size) when updating the text through TextItem.setText()? or do I need to destroy/re-create a TextItem?
It is not documented, but the method you want is TextItem.setHtml().
1.2
true
1
3,402
2014-10-01 07:18:17.923
Breadth first search how to find a particular path out of several branches
So I understand breadth first search, but I am having trouble with the implementation. When there are multiple branches you are expanding the edges or successors of each branch on every iteration of the function. But when one of your nodes returns GOAL how do you get all of the previous moves to that location? Do you...
I found the answer. The split lists was a bad idea. I used linked lists instead. You can create a class called "Node" then connect the nodes yourself. Once of the properties of the node is the parent node. With the parent node, you can track all the way back up the tree. Look into linked lists.
1.2
true
1
3,403
2014-10-01 07:53:47.273
use dev_appserver.py for specific file in a directory
In order to start Google app engine through the cmd i use: dev_appserver.py --port=8080, but i can't figure how does it pick a file to run from the current directory. My question is, is there an argument specifying a file to run in the server from all possible files in the directory?
dev_appserver doesn't "run a file" at all. It launches the GAE dev environment, and routes requests using the paths defined in app.yaml just like the production version. If you need to route your requests to a specific Python file, you should define that in app.yaml.
1.2
true
1
3,404
2014-10-01 09:43:13.030
Using threads with python pyqt?
I am trying to make a GUI in python using pyqt4 which incorporates a waterfall sink which is connected with an USRP. The problem is that the data should be shown in waterfall sink continuously which makes the GUI to freeze and I can not use the other buttons in meanwhile. I was checking to use threads, but till now wha...
There are several ways to do this, but basically either Breakup your waterfall sink into chunks of work, which the GUI can execute periodically. For example, instead of continuously updating the waterfall sink in a function that GUI calls, have only a "short" update (one "time step"), and have the function return righ...
0
false
1
3,405