Title
stringlengths
15
150
A_Id
int64
2.98k
72.4M
Users Score
int64
-17
470
Q_Score
int64
0
5.69k
ViewCount
int64
18
4.06M
Database and SQL
int64
0
1
Tags
stringlengths
6
105
Answer
stringlengths
11
6.38k
GUI and Desktop Applications
int64
0
1
System Administration and DevOps
int64
1
1
Networking and APIs
int64
0
1
Other
int64
0
1
CreationDate
stringlengths
23
23
AnswerCount
int64
1
64
Score
float64
-1
1.2
is_accepted
bool
2 classes
Q_Id
int64
1.85k
44.1M
Python Basics and Environment
int64
0
1
Data Science and Machine Learning
int64
0
1
Web Development
int64
0
1
Available Count
int64
1
17
Question
stringlengths
41
29k
In Python, how do I execute a .exe file, and stop it after n seconds?
18,743,249
0
0
1,986
0
python
subprocess.check_call is used to check the returned value - use subprocess.Popen this returns a process ID, (pid), which can be used after your time limit with pid.terminate() to end the process, (kill it).
0
1
0
0
2013-09-11T13:39:00.000
1
0
false
18,742,845
1
0
0
1
I am using "subprocess" to execute a .exe file from a Python script. I need to do this in a loop, ie start the .exe, run it for a minute, kill it, do it all over again. I am using subprocess.check_call to execute it with arguments, but I don't know how to stop it.
noob, but I installed python 2.7.5 on my mac, how to I "target" that one rather than the built in 2.7.2?
18,748,089
1
1
257
0
python,macos,pip
Honestly, one way around this is to make sure that virtualenv works with the right version, and just use pip inside the virtualenv.
0
1
0
0
2013-09-11T17:54:00.000
2
1.2
true
18,748,060
1
0
0
1
I went thought and installed pip and then added a bunch of libraries that I like to use and then, only after installing everything, did I realize that everything went into the 2.7.2 sit-packages directory, so the Python2.7.5 version doesn't see anything. Now, If I type python --version in the terminal, the correct version is started. However, pip is still "tied" to the default version of Python. How do I go about telling OSX to look at the new version of Python for everything?
Python remote programming / debugging
18,763,976
0
0
237
0
linux,windows,python-2.7,ide,remote-debugging
Beaglebone can do whatever we want to do in a a linux PC. But it is slower than PC so compile in pc and run in beaglebone via SSH is better way.
0
1
0
1
2013-09-11T21:09:00.000
1
1.2
true
18,751,328
0
0
0
1
I want to program beaglebone black(linux) from PC(linux/windows) using any Python IDE (scientific IDE's like anaconda/python(xy) is preferred). How can I do that? How I can configure the systems? Sincerly.
Upgrading to Python 2.7 Google App Engine 500 server error
18,774,464
2
0
198
0
python,google-app-engine,python-2.7,server-error
I'm not sure if this is your formatting when you loaded your code here, but where you define app in main.py should not be part of the contacts class. If it is, your reference to main.app in your app.yaml won't work and your page won't load.
0
1
0
0
2013-09-12T02:08:00.000
3
0.132549
false
18,754,202
0
0
1
3
I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic "template" I downloaded from a website was old and used Python 2.5. So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard). I have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong. I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong?
Upgrading to Python 2.7 Google App Engine 500 server error
18,778,368
0
0
198
0
python,google-app-engine,python-2.7,server-error
Thank you everyone for your respective answers and comments, but I recently stumbled upon GAE boilerplate and decided to use that and everything's fine. I kept having very odd problems with GAE beforehand, but the boilerplate is simple and seems to be working fine so far. Anyways, thanks again. (Note: I would delete the question but two people have already answered and received rep from +1s, and they are in fact helpful answers, so I'll leave it be).
0
1
0
0
2013-09-12T02:08:00.000
3
1.2
true
18,754,202
0
0
1
3
I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic "template" I downloaded from a website was old and used Python 2.5. So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard). I have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong. I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong?
Upgrading to Python 2.7 Google App Engine 500 server error
18,754,606
2
0
198
0
python,google-app-engine,python-2.7,server-error
I'm submitting as an answer because I'm relatively new to SO and don't have enough rep to comment, so sorry about that... But line 7 of your new main.py uses webapp instead of webapp2, so that may be causing some troubles, but likely isn't the reason that it's not working. Could you also provide the contact.html template?
0
1
0
0
2013-09-12T02:08:00.000
3
0.132549
false
18,754,202
0
0
1
3
I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic "template" I downloaded from a website was old and used Python 2.5. So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard). I have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong. I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong?
Python's ConfigParser: Cross platform line endings?
18,756,706
2
1
1,432
0
python,newline,configparser
You're fine, ConfigParser will still work. The reason is that is uses fp.readline, which reads up to and including the next LF (\n). The value is then stripped of whitespace, which removes the CR (\r). I'd say just use LF (\n) as your line separator - it will work on both systems, but using both won't cause any harm either. Edit: In fact, if you generate a file using ConfigParser.RawConfigParser it will use \n as the line separator.
0
1
0
0
2013-09-12T05:13:00.000
1
1.2
true
18,755,831
1
0
0
1
Does anyone know how Python deals with ConfigParser line endings in the different OSes? Because it follows the Windows INI format. But what about Linux? (As you know, Windows text line endings are typically CRLF, and Unix's are CR.) I want users of my app to take their config files (.INI files) easily from Windows to Linux and I'd like to know if that's going to be problematic. If it does use different line endings for Unix and Windows, what do you recommend?
After converting python script to executable with pyinstaller I get: error while loading shared libraries... Permission denied
18,767,999
0
0
550
0
python,pyinstaller
Looks like os.system('sudo useradd user') solved the issue.
0
1
0
0
2013-09-12T10:39:00.000
1
1.2
true
18,761,985
1
0
0
1
I have a python script which adds a user using the command os.system('useradd user'). This code works fine when run like a python script like this sudo python script.py. However, once I convert it to executable with pyinstaller with the command python pyinstaller.py --onefile script.py, and run the executable like this sudo ./script, I get an error useradd: error while loading shared libraries: libselinux.so.1: failed to map segment from shared object: Permission denied. Any idea what is the issue and how to fix?
python pip specify a library directory and an include directory
18,847,849
-3
88
69,488
0
python,shared-libraries,pip,include-path,pyodbc
Just in case it's of help to somebody, I still could not find a way to do it through pip, so ended up simply downloading the package and doing through its 'setup.py'. Also switched to what seems an easier to install API called 'pymssql'.
0
1
0
0
2013-09-13T09:56:00.000
7
-0.085505
false
18,783,390
1
0
0
1
I am using pip and trying to install a python module called pyodbc which has some dependencies on non-python libraries like unixodbc-dev, unixodbc-bin, unixodbc. I cannot install these dependencies system wide at the moment, as I am only playing, so I have installed them in a non-standard location. How do I tell pip where to look for these dependencies ? More exactly, how do I pass information through pip of include dirs (gcc -I) and library dirs (gcc -L -l) to be used when building the pyodbc extension ?
PIP uninstall not looking into /usr/local
21,244,963
1
2
1,195
0
python,ubuntu,pip
I do not really have a solution for the pip path lookup, but deleting /usr/local/lib/python2.7/dist-packages/_PACKAGE_NAME did the trick for me. At the very least it allowed me to install anew.
0
1
0
0
2013-09-13T16:01:00.000
1
1.2
true
18,790,639
1
0
0
1
I installed several packages (among them patsy and statsmodels) with pip 1.3.1 in kubuntu 13.04. They were put into /usr/local/lib, instead of /usr/lib. When using pip freeze or pip list, these packages appear fine, and are usable in python. However, when I use pip uninstall I get "Can't uninstall 'statsmodels'. No files were found to uninstall." The structure of install packages in /usr/local/lib/python2.7/dist-packages seem correct, and installed-files.txt has everything listed. How do I make pip see these files and uninstall them?
Debugging Cloud Endpoints: Error making request, but no request appears in logs
18,817,455
0
0
177
0
python,google-app-engine,google-cloud-endpoints
Check if you are running out of resources.
0
1
0
0
2013-09-14T14:48:00.000
2
0
false
18,802,940
0
0
1
1
I have an issue with debugging and Cloud Endpoints. I'm using tons of endpoints in my application, and one endpoint consistently returns with error code 500, message "Internal Error". This endpoint does not appear in my app's logs, and when I run its code directly in the interactive console (in production), everything works fine. There might be a bug in my code that I am failing to see, however, the real problem here is that the failing endpoints request is NOT showing up in my app's logs – which leaves me with no great way to debug the problem. Any tips? Is it possible to force some kind of "debug" mode where more information (such as a stack trace) is conveyed back to me in the 500 response from endpoints? Why isn't the failing request showing up in my app's logs?
Raspberry Pi crontab starts py script at bootup -> logging: error mysql 2002 (can't connect to local server)
18,811,200
1
0
1,257
0
python,mysql,crontab,raspberry-pi
solved the problem in quite ugly way, but it's working now. Just added: time.sleep(5) before trying to connect to mysql db. I would be pleased if someone has a better solution.
0
1
0
1
2013-09-14T19:18:00.000
1
1.2
true
18,805,490
0
0
0
1
A Raspberry Pi (raspian wheezy) has a cronjob, created as user pi with "sudo crontab -e" so it should has root grants. ps aux | grep /home/.../myscript.py ...say it's owner is user "pi"!? (is this correct?) The python script called from crontab is working fine if i call it from the terminal. It's reading data from UART (serial port), and save it into a mysql database. My python script got 'chmod 777' grants. The crontab file: @reboot sudo python /home/pi/pythonprogram/myscript.py & > /home/pi/pythonprogram/myscript.log crontab log file: Error mysql: 2002 Can't connect to local MYSQL server throught socket '/var/run/mysqld/mysqld.sock' (2) May it be that my script is called first, before the server (mysql and apache) are running during the boot up process? Is there a way to prevent this? What else could be the reason for those error?
Where does Web2py save project files OS X?
18,813,520
2
4
912
0
python,macos,web2py
If you are using the Mac binary, I think the applications are in /web2py/web2py.app/Contents/Resources/applications/. Note, you can also run the source version of web2py, in which case, the applications will be in /web2py/applications/.
0
1
0
0
2013-09-15T14:07:00.000
1
1.2
true
18,813,288
0
0
1
1
I am pulling my hair out trying to figure out where web2py stores the project files by default in OS X. It is not located in the same directoy as the web2py.app . I can launch the web interface and see project in the admin view but want to edit the files from sublime text as opposed to the admin web interface. I've looked through the web2py book and google user book with no luck. Any suggestions, this seems like it should be fairly obvious...
Porting compiled code (distutils) from Windows 7 to Windows Server
18,814,595
1
0
45
0
python,c,windows,compiler-construction,windows-server-2008-r2
Yes, but there are other issues you need to watch-out for. Are both systems either 32-bit or 64-bit? Not just the hardware, but the Python version as well. Are both systems running the same version of Python? That's tied to both major and minor version numbers (see sys.version_info). Edit: Your edit has answered these questions, so you should be fine. Make sure you keep any Python upgrades and modules in step, and only use the 64-bit versions.
0
1
0
0
2013-09-15T16:12:00.000
1
1.2
true
18,814,543
1
0
0
1
I installed a Python package (such as SQLAlchemy), and it compiled C into binaries on a Windows 7 machine. Can I expect to be able to reuse the compiled binaries on Windows Server 2008-R2? Edit: Both are AMD64 Python 2.7.3 and Windows 64 bit.
python 7z extraction with subprocess
18,833,072
1
1
2,735
0
python,subprocess,7zip
Set shell=False . Set the output directory to be '-o%s' % directory. You are prepending a space before the directory on the 7z command line.
0
1
0
0
2013-09-16T16:26:00.000
1
1.2
true
18,832,897
1
0
0
1
I try extract my archive using the subprocess: subprocess.call(['7z', 'x', '-r', '-y', '-o %s' % os.path.normpath("C:/temp"), archivePath], shell = True) but I get an error: 7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18 Processing archive: \172.16.0.30\TestFarm\testdata\testdata.7z Error: Can not create output directory C:\temp\ System error: The filename, directory name, or volume label syntax is incorrect. 2 How can I do it? Why it happens? If I use command line console it work perfect.
Arbitrary Code Execution with Docker
18,839,033
4
3
745
0
python,docker
Docker is indeed very suitable for this kind of usage. However, please note that docker is NOT yet ready for production usage. I would recommend to create a new container and give non-root privileges to your users to this container. One container per user. This way, you can prepare your docker image and prepare the environment and control precisely what your users are doing :)
0
1
0
0
2013-09-16T23:20:00.000
1
1.2
true
18,838,922
0
0
0
1
I'm thinking about building a web app that would involve users writing small segments of python and the server testing that code. However, this presents a ton of security concerns. Would docker be a good isolation tool for running this potentially malicious code? From what I've read, checking system calls with ptrace is a possibility, but I would prefer to use a preexisting tool.
Cannot Install Python Modules after Installing Anaconda
20,306,856
0
3
10,802
0
python,windows,python-2.7,pyodbc,anaconda
I suggest trying "conda install" + PackageName. If it fails installing using conda, it may automatically jump to using pip with success.
0
1
0
0
2013-09-17T02:21:00.000
6
0
false
18,840,292
1
0
0
1
[New Note: I cannot install through binstar or anaconda. Why can't I install in python, outside of anaconda? Is there a way to get my computer to stop using the anaconda install of python when I don't luanch it specifically through the continuum launcher?] I have an install of Python 2.7 on a windows machine. I just recently installed Anaconda, in addition. I just tried to install a new module for my Python install. I opened a command prompt in an unzipped folder for a python module and ran: python setup.py install However, I experienced an error at build line: building 'pyodbc' extension The ultimate error line reads: error: command 'gcc' failed with exit status 1 It appears to have looked for and not found several files or directories. For example, I received several (7) lines of error like: gcc.exe: error: /Wall: No such file or directory I have a wild hunch that the install of Anaconda is upsetting my PATH variables (or something), but it's just a hunch. Thanks kindly.
Automating scp upload without password
18,880,805
0
0
641
0
python,ssh-keys,pexpect,apscheduler,beagleboneblack
As a temporary workaround, I found I could schedule pulling from the server using APScheduler and pexpect.run along with scp. This is less than ideal, as I prefer to have the always running processes on the beaglebones, rather than the server, but it will suffice until I can schedule enough time to switch to Ubuntu. Still, if anyone has suggestions on how to get blackbear working, I would much like to hear them. Bit_Pusher
0
1
0
1
2013-09-17T18:26:00.000
1
0
false
18,857,206
0
0
0
1
I am working on having APScheduler upload a data file periodically using pexepect.run('scp ...'). The scp command works fine from the command line without password authentication (keys have been shared). However, when running in a python script on Beaglebone Black (started from a remote machine using pexpect), scp fails because blackbear (which replaces openssh on the BBB) doesn't load the private key properly. When I add -i ~/.ssh/id_rsa, then I get an error from /usr/bin/dbclient: Exited: String too long; dbclient is part of blackbear and this appears to be bug. When trying to convert my private key using >dropbearconvert openssh dropbear id_rsa id_rsa.db, I get the error: Error: Ciphers other than DES-EDE3-CBC not supported. I tried to install openssh, but this didn't work due to a conflict with blackbear. Just before I give up on Angstrom and go to Ubuntu, are there any suggestions.? I have already added a lot to Angstrom so changing operating systems at this time is painful. Thanks. Bit_Pusher
You Tube API Calls
18,857,640
0
0
63
0
python,youtube-api
Most google api code snippet require the user to input their personal API KEY. Please be sure you have appropriately updated the code snippet to use your api key.
0
1
0
1
2013-09-17T18:48:00.000
1
0
false
18,857,599
0
0
0
1
I have cut and pasted a python code sample from Google API to access You Tube video viewing data of my companies videos. The application will be scheduled and get usage data then write to a database on the server ( CENTOS ). I have tried both Simple API and installed application types. Is there a solid samle type that you know of or anyone else having issues with the API calls? My latest error is that the JSON file is not organized correctly ( which I got from the API page unaltered ).
Fine-grained authorisation with ZODB
18,883,943
1
0
86
0
python,zodb
No, ZEO was never designed for such use. It is designed for scaling ZODB access across multiple processes instead, with authentication and authorisation left to the application on top of the data. I would not use ZEO for anything beyond a local network anyway. Use a different protocol to handle communication between game clients and game server instead, keeping the ZODB server side only.
0
1
0
0
2013-09-18T12:22:00.000
1
1.2
true
18,872,148
0
0
0
1
I have been looking into using ZODB as a persistence layer for a multiplayer video game. I quite like how seamlessly it integrates with arbitrary object-oriented data structures. However, I am stumbling over one issue, where I can't figure out, whether ZODB can resolve this for me. Apparently, one can use the ClientStorage from ZEO to access a remote data storage used for persistence. While this is great in a trusted local network, one can't do this without proper authorization and authentication in an open network. So I was wondering, if there is any chance to realize the following concept with ZODB: On the server-side I would like to have a ZEO server running plus a simulation of the game world that might operate as a fully authorized client on the ZEO server (or use the same file storage as the ZEO server). On the client side I'd need very restricted read/write access to the ZEO server, so that a client can only view the information its user is supposed to know about (e.g. the surrounding area of their character) and can only modify information related to the actions that their character can perform. These restrictions would have to be imposed by the server using some sort of fine-grained authorisation scheme. So I would need to be able to tell the server whether user A has permissions to read/write object B. Now is there way to do this in ZODB or third-party solutions for this kind of problem? Or is there a way to extend ZEO in this way?
Existing HTML website, but processing on Google App Engine?
18,884,880
2
0
67
0
python,html,google-app-engine
you can make a post request to whatever http resource you want in your html form you can change the action to point at your gae python script <form action="http://yourdomain/your/gae/endpoint" method="post"> You can then follow the tutorial and access the posted data accordingly. Finally, it is up to you to return an appropriate response, this might include redirecting back to the original domain, dependent on your application
0
1
0
0
2013-09-19T01:18:00.000
1
1.2
true
18,884,852
0
0
1
1
I have a website hosted already and it contains an HTML form. I want to be able to submit the form to a Python script on Google App engine to handle the data. In the documentation, there is a tutorial to process forms with Python, but it was from a page that was served in the script itself. How do I link an existing domain/webpage to a script running on Google App Engine? Thanks for any help! ~Carpetfizz
How to uninstall OpenERP-7 module in ubuntu 12.04 ?
18,888,839
0
0
1,437
0
python-2.7,ubuntu-12.04,openerp
uninstallation of module will surely bring up some surprises with openerp, so better to test the module for functionality and features in a test system and when you are sure about things install it in LIVE system. For your problem, just check if there is any aeroo report is in the system, if yes delete the report and it's actions manually.
0
1
0
0
2013-09-19T07:10:00.000
1
0
false
18,888,331
0
0
1
1
I am using OpenERP 7 with Ubuntu 12.04. I have been trying to install Aero Reports module for creating OpenERP reports. I faced some "XML issues " during installation. Now when I try to remove the module it says "Integrity Error The operation cannot be completed, probably due to the following: - deletion: you may be trying to delete a record while other records still reference it" .Plz help me to fix this issue Hopes for suggestion
Writing an "interactive" client with Twisted/Autobahn Websockets
18,913,092
3
8
2,363
0
python,websocket,twisted,autobahn
Why do you need a thread to launch protocolInstance.sendMessage() ? This can be done in a normal reactor loop. The core of a twisted is reactor and it gives a much easier look at things when you consider twisted itself reactive - meaning it does something as a reaction (response) to something else. Now I assume that the thread you are talking about, also gets created and made in calling sendMessage because of certain events or activity or status. I can hardly imagine a case where you would just need to send a message out of the blue without any reason to react. If however there is an event which should trigger sendMessage, there is no need to invoke that in thread: just use twisted mechanisms for catching that event and then calling sendMessage from that particular event's callback. Now on to your concrete example: can you specify what "whenever I need" means exactly in the context of this question? An input from another connection? An input from the user? Looping activity?
0
1
0
0
2013-09-19T15:55:00.000
2
0.291313
false
18,899,515
0
0
1
1
Maybe I'm missing something here in the asynchronous designs of Twisted, but I can't seem to find a way to call the sendMessage() method "externaly". By this I mean, sending messages without being solely at the callback methods of Twisted/AutobahnWebsockets (like at onOpen or when receiving data from server at onMessage()) Of course I could launch a thread and call my_protocol_instance.sendMessage("hello") but that would defeat every purpose of the asynchronous design right? In a concrete example, I need to have a top wrapper class which opens the connection and manages it, and whenever I need I call my_class.send_my_toplevel_message(msg). How can I implement this? Hope I've been clear on my explanation. Thanks
ipython: Can I provide input to a shell command
28,972,659
1
5
4,131
0
shell,ipython,ipython-notebook
Was just looking for this and my wee face dropped when I saw it was a bit of an issue. Thought I would just post my solution in case it is usefull to anyone else. Basically I was looking for a way to send sudo commands through the notebook, probably not very wise but I needed it for what I was doing. And i couldn't get a prompt for the password. So decided to use a x-terminal and sending the command through to the terminal. You don't get any feed back but may be due to not hooking to the IO on the way back. Here is what i used in the notebook: In [1] !xterm -e sudo mount -o loop system.img /system/ I'm using linux but i would expect !cmd for windows might do the trick too
0
1
0
0
2013-09-20T00:28:00.000
4
0.049958
false
18,907,103
1
0
0
1
Can I execute a shell command that requires input in ipython and/or an ipython notebook? When I execute such a command, I see it's prompt, but no apparent way to provide it with input from my keyboard. An example could be an rsync command to a remote server (thus requiring a password). There are no doubt dangers security-wise here - these are somewhat reduced in my case as I'm running on localhost.
Writing to log files in a non-blocking manner in Tornado/Python
18,950,083
1
1
501
0
python,tornado
Tornado uses the standard library's logging module, which is blocking in most configurations. Python 3.2 includes a QueueHandler class which can be used to move the actual I/O to a separate thread; prior to that there was no standard solution to non-blocking logging (but there's probably a package on PyPI with a 2.x-compatible implementation).
0
1
0
0
2013-09-20T14:01:00.000
1
1.2
true
18,918,682
0
0
0
1
I am using Tornado for a websockets server and I am trying to figure out how to log to a file without blocking the main thread. Is tornado.log non-blocking? If not, is there a general pythonic way to log to a file without blocking the main thread? Thanks!
Suppressing windows command line PAUSE command
18,936,954
-1
3
2,666
0
batch-file,wix,continuous-integration,teamcity,python-2.5
First of all, there is no a well behaved way to supress the PAUSE command; however, it is possible to do that in a very simple way. The method consist in modify the cmd.exe file, that is, you may use a binary-hex editor to load cmd.exe file, look for the PAUSE command (that is encoded in two-bytes UNICODE characters), modify it by a different command and save the cmd.exe file. After that, the PAUSE command will no longer work. Yes, I know that there are multiple reasons to NOT do that; however, I am just answering the question. The OP is responsible to evaluate if this method would be useful for their needs or not.
0
1
0
0
2013-09-21T13:47:00.000
2
-0.099668
false
18,933,331
0
0
0
2
I have been tasked with consolidating out entire teams' build process. Including build servers, CI, etc. The way our project is structured is that each sub team is responsible for the development of their own code bases. Over time, each team has usually created their own python/sh/bat/Wix depending on the requirements of their deployment. I've been tasked with consolidating all the builds into one primary Team City system. Problem is that I've found that many build scripts (bat files) contain commands such as UI prompting and PAUSEing. Does anybody know of any way to perhaps suppress those commands prior/during the script execution. I have considered preprocessing the batch files and removing/REM'ing the Pauses but that is not ideal. Since there are +- 350 individual projects spread across +- 35 HG repositories (which are, in themselves, spread across 4 cities). Ideally we don't want to perform pre-building cleanup. Does anyone know of any supper-dupper magic trick to do this or does it required making changes to each build file,
Suppressing windows command line PAUSE command
18,934,862
12
3
2,666
0
batch-file,wix,continuous-integration,teamcity,python-2.5
You can disable input by redirecting input to nul: <nul yourScrpt.bat. This will effectively disable any PAUSE commands, but it will also disable any SET /P or other command that prompts for input. If you disable input for a master bat script that calls other scripts, the child scripts will inherit the disabled input.
0
1
0
0
2013-09-21T13:47:00.000
2
1
false
18,933,331
0
0
0
2
I have been tasked with consolidating out entire teams' build process. Including build servers, CI, etc. The way our project is structured is that each sub team is responsible for the development of their own code bases. Over time, each team has usually created their own python/sh/bat/Wix depending on the requirements of their deployment. I've been tasked with consolidating all the builds into one primary Team City system. Problem is that I've found that many build scripts (bat files) contain commands such as UI prompting and PAUSEing. Does anybody know of any way to perhaps suppress those commands prior/during the script execution. I have considered preprocessing the batch files and removing/REM'ing the Pauses but that is not ideal. Since there are +- 350 individual projects spread across +- 35 HG repositories (which are, in themselves, spread across 4 cities). Ideally we don't want to perform pre-building cleanup. Does anyone know of any supper-dupper magic trick to do this or does it required making changes to each build file,
Python App Engine's urllib2: works locally but not when deployed to GAE
18,948,829
0
1
225
0
python,google-app-engine,urllib2
We make no guarantees that urlfetch calls will all go out on the same IP address.
0
1
0
0
2013-09-22T19:59:00.000
1
1.2
true
18,948,174
0
0
1
1
I have an App that worked well on both GAE and test server till a few days ago. It connects to a remote site, logs in and browse pages and input information automatically. The remote site is using dynamic URLs to follow the session, each page gives the link for next call. The program is very basic : urllib2.urlopen then regexp to extract the next url key then new call to urllib2.urlopen and so on. Now my app works still perfectly on test server but fails when deployed on GAE : I have a series of calls to urllib2.open and most of the time, the remote site says it has lost the session already on the second call but 1/10th I could go to the third call and once GAE has gone successfully to the fourth call. This seems to point out that it is not a security issue with the remote site (which has not changed) nor a question of redirect and cookies I have read in other posts. Users reported to me that it worked well till the 14th of Sept 13 and the failure was reported to me on the 20th. Was there a change in the handling of URLfetch in GAE recently? I've just spent 2 days on the problem with no tangible clue. It may be a question of IP address? The remote server could control the session with the IP adress and the dynamicURL together and I can imagine that GAE does not garantee that in a same call to GAE, all calls to URLlib are handled by the same machine? This could explain why sometimes it works for two or three successive URLs. I do not know enough GAE internal mechanism to confirm. Thank you in advance for your ideas.
Use of shebang in shell scripts
18,964,952
2
3
704
0
python,linux,shell
There’a subtle distinction here. If the target is a binary or begins with a #! shebang line, then the shell calls execv successfully. If the target is a text file without a shebang, then the call to execv will fail, and the shell is free to try launching it under /bin/sh or something else.
0
1
0
0
2013-09-23T16:42:00.000
5
1.2
true
18,964,553
1
0
0
3
In Linux, we usually add a shebang in a script to invoke the respective interpreter. I tried the following example. I wrote a shell script without a shebang and with executable permission. I was able to execute it using ./. But if I write a similar python program, without shebang, I am not able to execute it. Why is this so? As far as my understanding, shebang is required to find the interpreter. So how does shell scripts work, but not a python script?
Use of shebang in shell scripts
18,964,586
4
3
704
0
python,linux,shell
shell scripts will only work if you are in the shell you targeted ... there is not python shell ... as such python will never work without explicity calling python (via shebang or command line)
0
1
0
0
2013-09-23T16:42:00.000
5
0.158649
false
18,964,553
1
0
0
3
In Linux, we usually add a shebang in a script to invoke the respective interpreter. I tried the following example. I wrote a shell script without a shebang and with executable permission. I was able to execute it using ./. But if I write a similar python program, without shebang, I am not able to execute it. Why is this so? As far as my understanding, shebang is required to find the interpreter. So how does shell scripts work, but not a python script?
Use of shebang in shell scripts
18,964,583
5
3
704
0
python,linux,shell
My assumption is that a script without a shebang is executed in the current environment, which at the command line is your default shell, e.g. /bin/bash.
0
1
0
0
2013-09-23T16:42:00.000
5
0.197375
false
18,964,553
1
0
0
3
In Linux, we usually add a shebang in a script to invoke the respective interpreter. I tried the following example. I wrote a shell script without a shebang and with executable permission. I was able to execute it using ./. But if I write a similar python program, without shebang, I am not able to execute it. Why is this so? As far as my understanding, shebang is required to find the interpreter. So how does shell scripts work, but not a python script?
GAE - updating structured properties ndb
18,994,112
-1
2
356
0
python,google-app-engine
Thank you for looking out but figured it out. Appending the object to a list did the trick but I am sure there is a better efficient way.
0
1
0
0
2013-09-23T23:08:00.000
1
-0.197375
false
18,970,356
0
0
1
1
Is there a way to update an object and its properties within an ndb StructuredProperty object instead of appending?
Getting PyDev suspend to work on threads other than MainThread
19,946,760
-2
5
2,402
0
python,multithreading,pydev
Given that Python doesn't really do threads properly (the GIL is bound to cock things up one way or another) I wouldn't be surprised if debugging them was a less than thrilling experience. If it comes to that it's not that good an experience either debugging C/C++ threads, even under the latest versions of GDB and CDT. I don't actually know for sure but I've a hunch that adopting multiple processes in Python instead of multiple threads might make your experience better. If you arrange things so that a single instance of Eclipse/PyDev was debugging a single Python process you might end up with a lot of windows on your screen but it will be a much more flexible debugging experience. Thats what I used to do under VxWorks in C, where there was no threads or processes just tasks. A consequence was that you could run a debugger for each task and it was wonderful.
0
1
0
0
2013-09-23T23:16:00.000
3
-0.132549
false
18,970,452
1
0
0
1
I have a multithreaded Python application running on a Linux server. I can use PyDev's Debug Server to remotely debug into it, which seems like a very valuable debug resource. There is however a problem I'm seeing that's preventing it from being as helpful as I would like. While my application is running on the server, I can go into Eclipse on the other box, suspend MainThread, get a nice stack trace of what it was up to at the time, then resume execution. It's great. However, when I try that on one of the child threads, the suspend button grays out but there's no stack trace and everything just keeps on running as normal. I can see in the Debug window that there IS a child thread and it's PID, but can't really control it or see what it is up to. Right-clicking and trying the helpful-sounding "copy stack" only gives me "Thread-4 - pid29848_seq5". Breakpoints seem to work okay. If a child thread hits one of those, I can step through and watch variables and such. However, using that effectively requires me to already have a specific point of interest in the code. I'm really more looking to run my application and, when it gets into an unusual state, use PyDev to see what's up. Do I have something wrong with my setup? Is this just a limitation of PyDev I'm up against? How can I see what's going on with the child threads?
confusion with results of `python setup.py install --user`
18,973,151
1
1
2,255
0
python,installation,setup.py
Instead of using --user, why not use a virtualenv? they are much more flexible, and put its bin directory on the path when activated. Otherwise, manually putting ~/.local/bin on your PATH, as you did, is what you need to do.
0
1
0
0
2013-09-24T03:49:00.000
1
0.197375
false
18,972,662
1
0
0
1
Say I have a python application that I want to install and if I run python setup.py install --user, everything gets put into ~/.local as expected (on linux), and inside of that the stuff in ~/.local/lib/python2.7/site-packages/ gets seen by the PYTHONPATH as expected; however, my executables that are created by setup.py (using either entry_points via setuptools or scripts via distutils) are correctly put into ~/.local/bin, but are not seen by the PATH at the command line. Thus, I have to add $HOME/.local/bin to my PATH (via my .zshrc) to get these executables seen by my environment. I'm assuming this is the expected behaviour, but my question is, is there some way to get my executables "registered" with my PATH when I run the installation with the --user flag during the setup? I believe this should work, as I see that ipython does something like this, where if it's installed with the --user flag (into ~/.local), then you don't have to add to your path ~/.local/bin to get the local install of ipython seen at the command line. I just can't figure out how ipython does it. Many thanks in advance.
How to execute .exe file in a remote windows machine using python
18,977,803
0
0
1,224
0
python,windows,remote-access
use command line program psexec. if you need to control remote computer through python I recommend you install on the remote computer rpyc. on the website of rpyc there is documentation on how to use it.
0
1
0
0
2013-09-24T09:27:00.000
1
0
false
18,977,699
1
0
0
1
I have a Executable file in remote windows machines.How can I execute .exe file remotely using python? or How can I get access to remote windows command line?.Please help. I have credentials of remote windows machines? PS: All remote windows machines are in a same network
Do I need celery when I am using gevent?
18,992,940
6
5
2,856
0
python,django,celery,gevent
In short you do need a celery. Even if you use gevent and have concurrency, the problem becomes request timeout. Lets say your task takes 10 minutes to run however the typical request timeout is about up to a minute. So what will happen if you trigger the task directly within a view is that the server will start processing it however after a minute a client (browser) will probably disconnect the connection since it will think the server is offline. As a result, your data can become corrupt since you cannot be guaranteed what will happen when connection will close. Celery solves this because it will trigger a background process which will process the task independent of the view. So the user will get the view response right away and at the same time the server will start processing the task. That is a correct pattern to handle any scenarios which require lots of processing.
0
1
0
0
2013-09-24T21:26:00.000
1
1.2
true
18,992,369
0
0
1
1
I am working on a django web app that has functions (say for e.g. sync_files()) that take a long time to return. When I use gevent, my app does not block when sync_file() runs and other clients can connect and interact with the webapp just fine. My goal is to have the webapp responsive to other clients and not block. I do not expect a zillion users to connect to my webapp (perhaps max 20 connections), and I do not want to set this up to become the next twitter. My app is running on a vps, so I need something light weight. So in my case listed above, is it redundant to use celery when I am using gevent? Is there a specific advantage to using celery? I prefer not to use celery since it is yet another service that will be running on my machine. edit: found out that celery can run the worker pool on gevent. I think I am a litle more unsure about the relationship between gevent & celery.
Why python uppercases all environment variables in windows
51,057,133
1
6
2,886
0
python,windows
Windows case insensitivity is a pain. Why would they do that? You can understand why searches should be case insensitive, but in most cases defined content should keep the exact value. Why? Well from experience it causes so many problems. I've never come across an issue where I've thought, "oh why wasn't that uppercased or lowercased?". From a Python point of view, why would they do that? Windows stores the key case sensitively, I'm guessing it is only some functions that get the value in a case insensitive manner, because I know for a fact that not all access functions do. I think MKS can tell the difference. Don't force platform specific behaviour (and be careful with forcing other behaviour) in an interface. Provide an alternative method to force case insensitivity, if required.
0
1
0
0
2013-09-26T08:35:00.000
2
0.099668
false
19,023,238
1
0
0
1
Is there any reason why os.environ contains all environment variables uppercase on Windows?, I don't understand why (only on windows) it doesn't load them on using the same case as it is defined ? Is there an equivalent implementation of os.environment that loads the environment variable information without modifying them for Windows? thanks
django celery: Import error - no module named task
25,423,925
0
4
2,154
0
django,python-2.7,celery
Try installing python-dev . This is a common error when python doesnt find the dependencies
0
1
0
0
2013-09-26T11:33:00.000
2
0
false
19,027,087
0
0
1
2
I am a beginner in django celery so unaware of the deep concepts of the celery. I have installed all the required packages like celery, rabbitMQ and permissions as well. after goin through the documentation of celery i have wrriten my code but when i am firing the command ./manage.py celery worker -c 2 I am getting-- ImportError: No module named tasks. all the changes in settings.py already done and in tasks.py i am importing-- from celery.task import task. I am not able to overcome this error. thanks..
django celery: Import error - no module named task
19,028,425
0
4
2,154
0
django,python-2.7,celery
If you do ./manage.py startapp sitetasks and put your tasks.py inside the new app-directory (/sitetask/) and then add sitetaks to you install_apps in settings.py. Does that help?
0
1
0
0
2013-09-26T11:33:00.000
2
0
false
19,027,087
0
0
1
2
I am a beginner in django celery so unaware of the deep concepts of the celery. I have installed all the required packages like celery, rabbitMQ and permissions as well. after goin through the documentation of celery i have wrriten my code but when i am firing the command ./manage.py celery worker -c 2 I am getting-- ImportError: No module named tasks. all the changes in settings.py already done and in tasks.py i am importing-- from celery.task import task. I am not able to overcome this error. thanks..
Find MAC address of system, using python (in chat system)
19,076,713
0
0
221
0
python,macos,chat
In general, it's not possible to get a MAC address of another host (computer) on the internet without running your own program on that host, and asking. It's possible to get the MAC addresses of the active hosts on the local network (up to the next router) from the ARP cache. It's possible to get your own MAC address(es). All this is OS-dependent.
0
1
0
1
2013-09-29T09:34:00.000
1
0
false
19,076,464
0
0
0
1
Is there any way to find MAC address of a device (in chat system) using Python? except uuid library
Celery default configuration file
19,090,686
0
0
407
0
python,celery
I prefer put configs to project root folder: One easy style to load config. One easy style to find and edit config. However you should load configs manually with one of next methods: config_from_object, config_from_envvar or config_from_cmdline.
0
1
0
0
2013-09-29T10:08:00.000
1
0
false
19,076,762
0
0
1
1
I am installing Celery through Puppet and I would like to also have a default configuration file to provide to Celery. The default name is celeryconfig.py, but I don't know where to copy it. I am NOT using Celery with Django. What is the location where I should copy celeryconfig.py in order for Celery to read it everytime it runs?
How to load data in Python for which data is stored as a customized class
19,085,226
0
1
137
0
python
Check sys.path. Does it contain the location where utility.py is kept? Does it have current directory ( an empty string )? That could be the issue.
0
1
0
0
2013-09-30T00:27:00.000
1
0
false
19,084,860
1
0
0
1
I have a question with loading data in Python. Basically, I defined all Classes I need in a file called "utility.py". and I have one data file "result.data" which stores results in form of a specific class called "Solution" which is defined in "utility.py". What I want to do is to load "result.data" in another py. file (ex:new.py). From what I know, cPickle module is the one that can be used. So in new.py, I wrote "from utility import *", and "Sol=cPickle.load(open('Result.data'))". This works fine when I worked among windows based system. However, when I tried to load the result.data I generated in windows system to new.py file in linux or mac system, The error "ImportError: No module named utility" always occurs. I'm a not a professional programmer, and I just start to code in python. Could you please give some guide on how to solve this problem? Thank you in advance.
Pycharm Remote Python Interpreter over SSH Gateway, X11 forwarding
22,637,135
6
5
2,948
0
python,pycharm
I was able to the piggyback X11 forwarding through another ssh connection. Try setting the DISPLAY environment variable in your PyCharm run configuration like so: DISPLAY=localhost:102 Check the value of DISPLAY in the other connection to see exactly what the value should be.
0
1
0
0
2013-09-30T11:38:00.000
2
1
false
19,093,260
0
0
0
1
I want to configure PyCharm 3.0 to use a Remote Python Interpreter. The Problem is, I have to connect over a SSH Gateway: MyMachine -> Gateway -> Machine with Python When I connect via Cygwin I type the following: ssh -t user@gateway.com "ssh user@machineWithPython.com" Is there a way to achieve this in PyCharm? Another question, can I forward the X11 server to PyCharm (so that I can view the matplotlib plots on my machine?) Regards, m
Why I do not see realtime output in the output file?
19,105,021
6
3
2,279
0
python,file,output
There are two points at which your file can buffer - Python's internal buffers and the buffers on the operating system. This is a performance boost that avoids system calls and disk writes while the buffer is filling up. Calling file.flush() will push the internal buffer to the operating system. You can additionally call fsync to request the operating system to save to disk. Usually you can leave the operating system to do what it knows best, so calling flush is usually enough for most applications. The same is partially true for Python's internal buffer - it knows best in terms of performance, but you may require more frequent writes and be willing to pay the additional cost. The only way to know the exact cost is to measure it both ways.
0
1
0
0
2013-09-30T22:12:00.000
1
1.2
true
19,104,798
1
0
0
1
I thought writing a file gives real-time output, since it is so when I use C/C++ to write files. But when I run python program it seems the output file is always 0 byte until the whole program finished running. Even for the nohup python xxx.py &, the print stuff in the file nohup.out isn't realtime, and can only be seen after execution. I'm now running really big program and want to see the progress in the file, how can I achieve it?
get the list of programs currently running on Windows or Ubuntu
19,109,762
1
1
1,538
0
python,windows,qt,winapi,ubuntu
Afaik Qt itself will not allow you to do this, at least it did not in prior versions. To solve this for windows you will have to use win-api EnumProcesses while in linux you could use the /proc filesystem, which holds information about running processes
0
1
0
0
2013-10-01T06:36:00.000
3
0.066568
false
19,109,538
0
0
0
1
I want to get the list of programs that shows in the Applications tab of Windows Task Manager(include the application icon and its name) , I wonder which Windows APIs should I use ? If I want to do the same thing on Ubuntu ,then which Ubuntu APIs should I use ?
Wing101 - Configure python 3.3.2 from 2.7.2 on a mac
19,120,750
1
2
10,844
0
python,wing-ide
The location of the python.exe for Python 3.3 can vary depending on how you installed it. Probably the best bet is to search w/ Spotlight for python.exe, press "Show All" in the drop down menu, change to "File Name" instead of "Contents" search and then click on results to see the full path at the bottom of the search results window. You'll get at least 2-3 results and the full path should make clear which is the correct one. Then enter that into Python Executable in the Configure Python dialog, accessed from the Source menu in Wing 101. You'll need to restart the Python Shell in Wing 101 from its Options menu before it switches to the new Python version.
0
1
0
0
2013-10-01T15:30:00.000
1
1.2
true
19,120,229
0
0
0
1
I am relatively new to programming, and I am using Wing101 version: 5.0.0-b8 (rev 29847). The Python Shell within Wing101, is version 2.7.2, how do I configure it to open python 3.3.2. I have downloaded Python 3.3.2 and I need the custom Python Executable. I previously tried "/usr/bin/python" as my custom python executable, but it doesn't work. I am on a Mac 10.8.3
Tests fail ran by gitlab-ci, but not ran in bash
27,779,548
0
2
1,059
0
python,unit-testing,continuous-integration,gitlab
-i usually replicate the problem by using a docker container only for the runner and running the tests inside it, dont know if you have it setup like this =(. -Normally the test doesnt actually fail if you log in the container you will see he actually does everything but doesnt report back to the Gilab CI, dont freak out it does it job it simply does not say it. PS: you can see if its actually running by checking the processes on the machine. example: im running a gitlab ci with java and docker: gitlab ci starts doing its thing then hangs at a download,meanwhile i log in the container and check that he is actually working and manages to upload my compiled docker image.
0
1
0
1
2013-10-01T18:46:00.000
1
0
false
19,123,609
0
0
0
1
I'm using gitlab-ci to automatically build a C++ project and run unit-tests written in python (it runs the daemon, and then communicates via the network/socket based interface). The problem I'm finding is that when the tests are run by the GitLab-CI runner, they fail for various reasons (with one test, it stalls indefinitely on a particular network operation, on the other it doesn't receive a packet that should have been sent). BUT: When I open up SSH and run the tests manually, they all work successfully (the tests also succeed on all of our developers' machines [linux/windows/OSX]). At this point I've been trying to replicate enough of the build/test conditions that gitlab-ci is using but I don't really know any exact details, and none of my experiments have reproduced the problem. I'd really appreciate help with either of the following: Guidance on running the tests manually outside of gitlab-ci, but replicating its environment so I can get the same errors/failures and debug the daemon and/or tests, OR Insight into why the test would fail when ran by GitLab-CI-Runner Sidetrack 1: For some reason, not all the (mostly debugging) output that would normally be sent to the shell shows up in the gitlab-ci output. Sidetrack 2: I also played around setting it up with jenkins, but one of the tests fails to even connect to the daemon, while the rest do it fine.
Running a python script in background with raw_input command
19,143,751
1
1
1,513
0
python,background,raw-input
You probably want to run the script in the foreground, but then call os.fork() after the user has input the value.
0
1
0
0
2013-10-02T18:02:00.000
2
0.099668
false
19,143,658
0
0
0
1
I have a python script that has a raw input command, but I would like to run it in the background after the user inputs the raw_input part. The problem I have is if I try running the script in the background using &, the raw input pops up as a linux command and the python script doesn't recognize it. Any tips?
Is it possible to force ipengines to completely reset all local variables and imports?
19,647,089
0
2
182
0
ipython,ipython-parallel
My solution to this was to use the ipengine to start a new subprocess which completes the desired operations. This subprocess has its own memory. Not ideal, but provides the desired functionality.
0
1
0
0
2013-10-03T19:07:00.000
1
0
false
19,167,257
1
0
0
1
My workflow is: start ipcontroller/ipengines, then run 'python test_script.py' several times with different parameters. This script includes a map_async call. The ipengines don't recognize changes to the code between calls to the script, and static class variables are not reset to their defaults. It seems like a magic %reset call would do the trick, but attempting to execute this command on the ipengines does not seem to do anything.
Can Python program developed on 64-bit Windows run on all version of Windows?
19,173,661
4
0
111
0
python
Well-written pure Python programs (just .py files) are extraordinarily portable across all platforms. If you're using some way of packaging your program in a Windows executable (.exe file), then you have worlds of other possible problems. There are cases where a 64-bit program won't work on a 32-bit system, such as if your program uses massive data structures and you simply run out of address space on a 32-bit system. But, barring things like that, you should be fine. If you want more specifics, I'm afraid you'll need to be more specific ;-)
0
1
0
0
2013-10-04T05:03:00.000
3
0.26052
false
19,173,616
1
0
0
2
I have developed a python application with 64-bit Windows 8 (the non metro version which looks like Windows 7 interface). I want to distribute it to all version of 64-bit Windows such as Windows XP, Windows 7 and etc. Is it possible for program developed with python to do that? Also, can the software run on 32-bit Windows os as well?
Can Python program developed on 64-bit Windows run on all version of Windows?
19,173,646
0
0
111
0
python
If you have not used any 64 bit specific items the your code should run fine on all versions of windows from source code with a minimum installation of python and the dependencies.
0
1
0
0
2013-10-04T05:03:00.000
3
0
false
19,173,616
1
0
0
2
I have developed a python application with 64-bit Windows 8 (the non metro version which looks like Windows 7 interface). I want to distribute it to all version of 64-bit Windows such as Windows XP, Windows 7 and etc. Is it possible for program developed with python to do that? Also, can the software run on 32-bit Windows os as well?
How to debug Python curses code using two terminal windows
19,185,691
0
2
459
0
python,debugging
IPython supports embedding a “kernel” which can then connect to an external front-end, such as a Qt one (qtconsole). For working with another tty, I’d suggest connecting the debugger with another tty either via a pair of pipes or a pty (pseudo terminal), although you’d probably have to write the “other half” to display in the terminal, whereas the qtconsole is already ready to use as-is. You install the Debian package ipython-qtconsole (or the Py3k version ipython3-qtconsole), then just run “ipython qtconsole” on the command line to get a GUI window containing the debugger. Embedding is also possible: you can modify your program to call the ipython “kernel” at some point which is like setting a breakpoint.
0
1
0
0
2013-10-04T15:47:00.000
1
0
false
19,185,466
1
0
0
1
I am writing a Python code using curses library under Linux. Are there any debugger does not share the same terminal, so I can debug alone with the code running? EDIT: I tried WinPDB, but it works only with python 2.7, and I am using 3.3
How to check if a network port is open?
20,727,394
3
95
151,151
0
python,port,netstat
Netstat tool simply parses some /proc files like /proc/net/tcp and combines it with other files contents. Yep, it's highly platform specific, but for Linux-only solution you can stick with it. Linux kernel documentation describes these files in details so you can find there how to read them. Please also notice your question is too ambiguous because "port" could also mean serial port (/dev/ttyS* and analogs), parallel port, etc.; I've reused understanding from another answer this is network port but I'd ask you to formulate your questions more accurately.
0
1
0
1
2013-10-05T09:24:00.000
13
0.046121
false
19,196,105
0
0
0
1
How can I know if a certain port is open/closed on linux ubuntu, not a remote system, using python? How can I list these open ports in python? Netstat: Is there a way to integrate netstat output with python?
How to use a library that imports memcache in App Engine
19,237,649
2
2
1,996
0
python,google-app-engine
To further clarify jayhendren's answer - if you are planning to use GAE's memcache service, you must use from google.appengine.api import memcache you cannot use an open source memcache library. The only scenario where you could use the standard python memcache lib is if you were running your own memcache service somewhere (e.g. on Compute Engine) and you wanted to connect out to that over a socket. I'm guessing you're not doing that. Assuming you want to use GAE's built in memcache service: since there are differences between the API defined by GAE's memcache lib and the standard python memcache libs, you will have to make some minor changes to memorised so that it can successfully talk to the GAE memcache library. For the most part though the developer facing functionality is the same as the standard python lib. If you get it working, let us know!
0
1
0
0
2013-10-06T17:00:00.000
4
0.099668
false
19,211,444
0
0
1
1
I want to use a library (memorised) that uses memcache like this: import memcache Now on App Engine, memcache must be imported like this: from google.appengine.api import memcache So I get this error when running with dev_appserver.py: ImportError: No module named memcache Can I use this library without modifying it?
understanding python twisted asynchronicity in terms of operating system
19,211,645
5
6
394
0
python,asynchronous,twisted
It's hard to talk about this without defining a lot of terms more precisely and taking issue with your facts, but here's my attempt: Question 1: Try man select, which is approximately how Twisted is implemented - it's a way to ask the operating system to monitor several things at once and let the application know when any one of them fires (block on multiple things). Question 2: Yeah, pretty much - but you're wrong about Javascript, it's just like Twisted.
0
1
0
0
2013-10-06T17:14:00.000
3
1.2
true
19,211,578
1
0
0
1
I'm new to the twisted library and I'm trying to understand how it is done that operations in python/twisted are performed asynchronously. So far I thought that only GUI-alike (Qt or javascript) platforms use event-driven architecture extensively. facts: Twisted programs are run in one thread = no multithreading reactor and deferred patterns are used: callbacks/errbacks are declared and the execution of everything is controlled by reactor main loop a single CPU can never do anything truly parallelly, because it shares its resources between processes, etc. By parallel code execution I mean that the programming platform (python, javascript, whatever) executes more than one sequence of operations (which can be done, for example, using multithreading) question 1 Python could be seen as a high-level wrapper for the operating system. What are the OS functions (or C functions) that provide asynchronous operation handling? Are there any? question 2 Q1 leads me to an idea, that twisted's asynchronicity is not a true asynchronicity, like we have in Javascript. In JavaScript, for example, if we provide 3 different buttons, attach callback functions to them and we click all three buttons - then the 3 callbacks will be executed parallelly. Truly parallelly. In Twisted - as far as I understand - it's not true asynchronicity - it's, let's say, approximated asynchronicity instead, since no operations would be performed parallelly (in terms of code, as I mentioned in fact3). In Twisted the first n line of code (defining protocols, factories, connections, etc.) are the declarations of what is going to happen when entire system starts. Nothing runs so far. Real execution starts then the reactor.run() is fired. I understand that the reactor runtime is based on a single while True loop which iterates through events. The reactor checks any awaiting tasks to do, processes them, send their result back to the queue (either to callbacks or errbacks). In the next loop execution they'll be processed one step further. So the deferred execution is linear in fact (though, from outside it looks like it was executed parallelly). Is my interpretation correct? I'd appreciate if someone could answer my questions and/or explain how asynchronicity works in twisted/python platform and how is it related to operating system. Thanks in advance for good explanations! edit: links to articles explaining asynchronicity are very welcome!
How to load Cython compiled .so file on both Mac OS X and Linux?
19,223,474
5
2
1,310
0
python,linux,macos,cython
You can't. You'll have to compile a different library for each platform you need to support.
0
1
0
0
2013-10-07T11:16:00.000
1
0.761594
false
19,223,411
1
0
0
1
I compiled a module.pyx file to module.so under Mac OS X, and now I can use it with: from module import method1 However, the same .so file won't work on Linux, I have to compile a new module.so under Linux. So the problem is, how can I write a cross platform(Mac and Linux) module with Cython?
Why does powershell freeze for a bit when running my python scripts
19,229,832
6
6
1,655
0
python,powershell,windows-7
If it's intermittent with all other factors being unchanged, it sounds like you've inadvertently selected some text in the PowerShell console and it's halted updating output so that you can do something with it. Next time, be careful to look to see if you have something selected before clicking.
0
1
0
0
2013-10-07T15:04:00.000
2
1.2
true
19,228,271
1
0
0
1
Sometime I look back at my terminal when there is a python script running and the console output has frozen, then I right-click on the terminal and the console output (printing to screen) beings again. Its a bit disconcerting because sometimes I think my script has broken. Do others also experience this? Anybody know a fix? Thanks in advance for any responses
How to tell uWSGI to prefer processes to threads for load balancing
19,326,373
11
14
9,291
0
python,multithreading,process,load-balancing,uwsgi
So, the solution is: Upgrade uWSGI to recent stable version (as roberto suggested). Use --thunder-lock option. Now I'm running with 50 threads per process and all requests are distributed between processes equally.
0
1
0
0
2013-10-07T19:37:00.000
2
1.2
true
19,233,132
0
0
1
2
I've installed Nginx + uWSGI + Django on a VDS with 3 CPU cores. uWSGI is configured for 6 processes and 5 threads per process. Now I want to tell uWSGI to use processes for load balancing until all processes are busy, and then to use threads if needed. It seems uWSGI prefer threads, and I have not found any config option to change this behaviour. First process takes over 100% CPU time, second one takes about 20%, and another processes are mostly not used. Our site receives 40 r/s. Actually even having 3 processes without threads is anough to handle all requests usually. But request processing hangs from time to time for various reasons like locked shared resources, etc. In such cases we have -1 process. Users don't like to wait and click the link again and again. As a result all processes hangs and all users have to wait. I'd add even more threads to make the server more robust. But the problem is probably python GIL. Threads wan't use all CPU cores. So multiple processes work much better for load balancing. But threads may help a lot in case of locked shared resources and i/o wait delays. A process may do much work while one of it's thread is locked. I don't want to decrease time limits until there is no another solution. It is possible to solve this problem with threads in theory, and I don't want to show error messages to user or to make him waiting on every request until there is no another choice.
How to tell uWSGI to prefer processes to threads for load balancing
19,238,645
9
14
9,291
0
python,multithreading,process,load-balancing,uwsgi
Every process is effectively a thread, as threads are execution contexts of the same process. For such a reason there is nothing like "a process executes it instead of a thread". Even without threads your process has 1 execution context (a thread). What i would investigate is why you get (perceived) poor performances when using multiple threads per process. Are you sure you are using a stable (with solid threading support) uWSGI release ? (1.4.x or 1.9.x) Have you thought about dynamically spawning more processes when the server is overloaded ? Check the uWSGI cheaper modes, there are various algorithm available. Maybe one will fit your situation. The GIL is not a problem for you, as from what you describe the problem is the lack of threads for managing new requests (even if from your numbers it looks you may have a too much heavy lock contention on something else)
0
1
0
0
2013-10-07T19:37:00.000
2
1
false
19,233,132
0
0
1
2
I've installed Nginx + uWSGI + Django on a VDS with 3 CPU cores. uWSGI is configured for 6 processes and 5 threads per process. Now I want to tell uWSGI to use processes for load balancing until all processes are busy, and then to use threads if needed. It seems uWSGI prefer threads, and I have not found any config option to change this behaviour. First process takes over 100% CPU time, second one takes about 20%, and another processes are mostly not used. Our site receives 40 r/s. Actually even having 3 processes without threads is anough to handle all requests usually. But request processing hangs from time to time for various reasons like locked shared resources, etc. In such cases we have -1 process. Users don't like to wait and click the link again and again. As a result all processes hangs and all users have to wait. I'd add even more threads to make the server more robust. But the problem is probably python GIL. Threads wan't use all CPU cores. So multiple processes work much better for load balancing. But threads may help a lot in case of locked shared resources and i/o wait delays. A process may do much work while one of it's thread is locked. I don't want to decrease time limits until there is no another solution. It is possible to solve this problem with threads in theory, and I don't want to show error messages to user or to make him waiting on every request until there is no another choice.
GAE: is putting all handlers in main.py gonna make my app slow?
19,242,752
1
0
154
0
google-app-engine,python-2.7,webapp2
No, that doesn't affect the speed. Your code needs to be loaded anyway, so it makes no difference if it's all in one file or not. It will of course make the file more complex, but that's your problem, not GAE's.
0
1
0
0
2013-10-08T06:01:00.000
2
0.099668
false
19,240,218
0
0
1
2
I'm building a web application using GAE. I've been doing some research by my own on GAE python project structures, and found out that there isn't a set trend on how to place my handlers within the project. As of now, I'm putting all the handlers(controllers) in main.py, and make all urls (/.*) be directed to main.application. Is this going to make my application slower? Thank You!
GAE: is putting all handlers in main.py gonna make my app slow?
19,253,273
1
0
154
0
google-app-engine,python-2.7,webapp2
In general, this will not make your application slower, however it can potentially slow you down your instance start-up time, but it generally isn't a problem unless you have very large complicated apps. The instance start up time comes into play whenever GAE spins up a new instance for you. For example, if your app is unused for a long period and you start it up once in a long while, or for example, if your app is very busy and need a new instance to handle the load. python loads your modules as needed. So if you launch an instance, and the request goes to main.py, then main.py and all the modules associated with it will get loaded. If your app is large, this may take a few seconds. Let's just say for example it takes 6 seconds to load every module in your app. That's a 6 second wait for whoever is issuing that request. Subsequent requests to that loaded instance will be quick. It's possible to break down your handlers to separate modules. If handler for \a requires very little code, then having \a in a separate file will reduce the response time for \a. But when you load \b that has all the rest of the code, that would take a while to load. So it's possible to take that 6 second load and potentially break it up into a few requests that may take 2 seconds. This type of optimization really depends on the libraries you need to load with each request. You generally want to do this later on, when you run into the problems, rather than design your layout for this purpose up front, since it's pretty difficult to predict. App Engine warmup requests also help alleviate this problem.
0
1
0
0
2013-10-08T06:01:00.000
2
1.2
true
19,240,218
0
0
1
2
I'm building a web application using GAE. I've been doing some research by my own on GAE python project structures, and found out that there isn't a set trend on how to place my handlers within the project. As of now, I'm putting all the handlers(controllers) in main.py, and make all urls (/.*) be directed to main.application. Is this going to make my application slower? Thank You!
How to remove multiple versions of Python from the Windows registry
19,245,809
3
2
7,170
0
python,windows,registry,cx-freeze
I just resolved it but not sure if this is the right way to go about it. Here's what I did, In the cmd box, type regedit, and then click OK you will have the Registry editor. Right Clicked on the key name HKEY_LOCAL_MACHINE and searched for the wrong path name that kept showing up. In a few seconds it will take you to the location of that path in the registry. I did see two mentions of Python. Wasn't hard to figure out the wrong one(incorrect path) and deleted it without any side effects. Immediately after this I was able to install the modules perfectly.
0
1
0
0
2013-10-08T10:33:00.000
1
1.2
true
19,245,329
1
0
0
1
I was trying to install cx_Freeze module and it gives me the could not locate network location error along with a non existent path name(supposedly pointing to python? but it wasnt). Then I tried installing another module py2exe, this time the installer was a bit more user friendly and informed that I got two mentions of Python in my registry. One pointing to the correct Python directory, the other pointing to the same wrong one. My question is how or is it possible to delete the wrong mention of Python from my registry or another way around it? I wanted to install cx_Freeze. Thanks
Running web.py as a service on linux
19,256,882
1
0
855
0
python,centos,web.py
In general, there are two parts of this. The "remote and event-based" part: Service used remotely over network needs certain set of skills: to be able to accept (multiple) connections, read requests, process, reply, speak at least basic TCP/HTTP, handle dead connections, and if it's more than small private LAN, it needs to be robust (think DoS) and maybe also perform some kind of authentication. If your script is willing to take care of all of this, then it's ready to open its own port and listen. I'm not sure if web.py provides all of these facilities. Then there's the other part, "daemonization", when you want to run the server unattended: running at boot, running under the right user, not blocking your parent (ssh, init script or whatever), not having ttys open but maybe logging somewhere... Servers like nginx and Apache are built for this, and provide interfaces like mod_python or WSGI, so that much simpler applications can give up as much of the above as possible. So the answer would be: yes, you still need Nginx or the likes, unless: you can implement it yourself in Python, or you are using the script on localhost only and are willing to take some risks of instability. Then probably you can do on your own.
0
1
0
0
2013-10-08T19:28:00.000
2
1.2
true
19,256,594
0
0
1
1
I've used web.py to create a web service that returns results in json. I run it on my local box as python scriptname.py 8888 However, I now want to run it on a linux box. How can I run it as a service on the linux box? update After the answers it seems like the question isn't right. I am aware of the deployment process, frameworks, and the webserver. Maybe the following back story will help: I had a small python script that takes as input a file and based on some logic splits that file up. I wanted to use this script with a web front end I already have in place (Grails). I wanted to call this from the grails application but did not want to do it by executing a command line. So I wrapped the python script as a webservice. which takes in two parameters and returns, in json, the number of split files. This webservice will ONLY be used by my grails front end and nothing else. So, I simply wish to run this little web.py service so that it can respond to my grails front end. Please correct me if I'm wrong, but would I still need ngix and the like after the above? This script sounds trivial but eventually i will be adding more logic to it so I wanted it as a webservice which can be consumed by a web front end.
pytest is not parsing command line arguments on windows
19,256,758
0
0
552
0
python,command,pytest
I can't check this but what I'd do first would be check PATH for the pytest executable. I'd except a Windows batch script, and continue investigation in the code, maybe that's where the args are lost or passed (quoted?) incorrectly.
0
1
0
1
2013-10-08T19:30:00.000
1
0
false
19,256,629
0
0
0
1
I have 2.3.3 version of pytest running on windows. I have a test folder which contains bunch of test files like test1.py, test2.py, test3.py etc. If i open command prompt and navigate to this folder to run a particular test pytest test1.py Instead of just running test1.py, it is running all the tests in the folder. Like test1.py, test2.py, test3.py etc. So pytest is not taking arguments and parsing them. I am seeing this only on windows. Does anyone know what is happening here? Thanks a bunch in advance.
How to make shortcut work from PATH
19,271,370
0
1
2,981
0
python,windows,path
You could also work with Windows path: set path=C:\Python26;.;..;C:\windows;C:\windows\system32 prompt $ & start title Python26 Save this as Py26.bat and type Python in the screen that displays set path=C:\Python33;.;..;C:\windows;C:\windows\system32 prompt $ & start title Python33 Save this as Py33.bat and type Python in the screen that displays
0
1
0
0
2013-10-09T09:15:00.000
4
0
false
19,267,714
0
0
0
1
I have two versions of Python on Windows and want to use them through cmd. I tried to make shortcuts of their python.exe and renaming them to python26 and python33 (I also added their locations to PATH), but unfortunately this does not work. Calling python26 or python26.lnk outputs in not recognized as an internal command. Is there any other way to do it (like Linux virtualenv), or I missed something in my idea ?
Fast encrypt, slow decrypt method for NDB Datastore
19,318,479
1
0
560
0
python,google-app-engine,encryption
It sounds like conventional cryptographical methods should meet your needs, e.g. AES256. When it comes to crypto you should try to innovate as little as possible. Use well-established and well-trusted methods -- when "rolling your own" it's very easy to make mistakes, and you don't get the benefit of peer review from the academic cryptography community. Make sure to benchmark how long the encryption with the strong algorithm of your choice actually takes before doing work to address the issue of the encryption blocking the request. Would a few hundred milliseconds' delay really be a problem? If it turns out encryption is too slow, you still shouldn't compromise on the quality of your encryption algorithm. A better solution to this would be to perform the encryption in a background thread and continue with the request immediately. Allot an ID in your database to the resource that is to be inserted in encrypted form, but don't bother with an intermediate, intentionally "mild" form of encryption before the "real" encryption. This layer would only be providing a false sense of security. If a user attempts to access a resource that has not yet been encrypted, return an error indicating that the resource is still being processed (or that the encryption has failed, if applicable). Make sure that there's no possibility of the encryption process failing or being delayed in a way that results in unencrypted data being kept around for longer than it should. If encryption can't succeed in a timely manner (because of disks being full / power failure / cosmic rays), the insertion must simply be allowed to fail and the unencrypted data must not be kept.
0
1
0
0
2013-10-11T11:32:00.000
1
0.197375
false
19,317,126
0
0
1
1
I have unencrypted web request data (not under my jurisdiction) that I would like to quickly save into the Datastore so as not to slow down the request process. The sensitive data occasionally is required to be opened by system users via the web. When a user makes such a request, it will require them to complete a reCAPTCHA before the decryption process starts and an event is logged regarding their behavior. Decryption time could suitably be up to 1 minute long for a string of between 10 and 20 characters. Is there an encryption algorithm usable on GAE which is slower to decrypt than encrypt that would be suitable in this case? I'm contemplating another method to alleviate the encryption time: temporarily store the data mildly encrypted with MD5 & hash quick encryption method, while a scheduled job iterates over any records not flagged as properly encrypted and economically applies very strong encryption (it would be acceptable for the user to be alerted that encryption has not yet finished if they tried to access the data immediately after input) Assuming the above method is feasible, then I assume I can encrypt the pants out of the data for a few minutes, rendering it extremely costly to try to decrypt if data is compromised but system is not.
Using Python and Vim within the Mac Terminal
19,331,487
2
1
3,871
0
python,macos,vim,terminal
You can't execute a file if that file doesn't exist. Write the file with :w filename.py (further writes only need :w) and execute your script with :!python %. Learning programming and Vim at the same time is not a very good idea: Vim is a complex beast and trying to handle both learning curves won't be easy. As much as I love Vim, I'd suggest you use another text editor, at least in the beginning, like Sublime Text or TextMate. In short, focus on programming first by using a simple and intuitive editor and learn Vim once you are comfortable enough in your craft. Or don't, Vim is the greatest text editor but you can definitely be a successful programmer without it.
0
1
0
0
2013-10-12T05:13:00.000
5
0.07983
false
19,330,790
0
0
0
2
I'm writing Python code using Vim inside Terminal (typing command "vim" to start up Vim). I've been trying to find a way to execute the code through the mac terminal in the same window. I'm trying to use :!python % but I get the following error message: E499: Empty file name for '%' or '#', only works with ":p:h" Anyone have any suggestions?
Using Python and Vim within the Mac Terminal
64,542,587
-1
1
3,871
0
python,macos,vim,terminal
in vim type :w yourfilenamehere.py and press enter
0
1
0
0
2013-10-12T05:13:00.000
5
-0.039979
false
19,330,790
0
0
0
2
I'm writing Python code using Vim inside Terminal (typing command "vim" to start up Vim). I've been trying to find a way to execute the code through the mac terminal in the same window. I'm trying to use :!python % but I get the following error message: E499: Empty file name for '%' or '#', only works with ":p:h" Anyone have any suggestions?
How to find orphan process's pid
19,361,844
2
1
947
0
python,linux,process
The information is lost when a process-in-the-middle terminates. So in your situation there is no way to find this out. You can, of course, invent your own infrastructure to store this information at forking time. The middle process (PID 3 in your example) can of course save the information which child PIDs it created (e. g. in a file or by reporting back to the father process (PID 1 in your example) via pipes or similar).
0
1
0
1
2013-10-14T13:46:00.000
1
0.379949
false
19,361,740
0
0
0
1
How can I find child process pid after the parent process died. I have program that creates child process that continues running after it (the parent) terminates. i.e., I run a program from python script (PID = 2). The script calls program P (PID = 3, PPID = 2) P calls fork(), and now I have another instance of P named P` (PID = 4 and PPID = 3). After P terminates P` PID is 4 and PPID is 1. Assuming that I have the PID of P (3), how can I find the PID of the child P`? Thanks.
Python merging doc files into 1 doc file
19,363,269
0
1
999
0
python,merge,doc
You can open and read contents of each files and write them in a separate file. You can File I/O functions.
0
1
0
0
2013-10-14T15:00:00.000
2
0
false
19,363,207
1
0
0
1
In Python on Linux I would like to merge several .doc files into 1 .doc file? (The .doc file will be open in Windows machines). I have searched on internet but I don't find useful information. I know that this feature is working for PDF in GhostScript, but now it needs also working for doc files. Has somebody suggestions how to solve this issue?
Keymapping different between Python2.4 and Python2.7 on RedHat
32,932,552
-1
1
103
0
python,python-2.7,redhat,python-2.4
This page describes the main key differences between Python 2.4 and Python 2.7: Multithreading Python 2.4 : Not available. Python 2.7: You can use the Python 2.7 threading library. All threads in a request must finish before the request deadline (60 seconds for online requests and 10 minutes for offline). Concurrent requests Python 2.4 : Not supported. Python 2.7 :Can use concurrent requests as long as you specify the threadsafe directive in app.yaml. Script handlers must use the Python WSGI interface in order to be threadsafe. In backends, raising an exception from a shutdown hook copies that exception to all threads. Bytecode upload Python 2.4: Not available. Python 2.7: Can upload .pyc files, but not in combination with .py files. However, you can upload .zip files containing .py or .pyc files (or a combination). Preferred interface (WSGI vs. CGI) Python 2.4: CGI is the only supported interface. Python 2.7: WSGI is the preferred interface, and is required for multithreading. For more information about converting CGI handlers to WSGI, see Migrating to Python 2.7. Support for C modules Python 2.4: Some C modules are not available. See the libraries knowledge base for more information. Python 2.7: The following C modules are not available: ctypes, sqlite, ssl, _ssl, fcntl, spwd, pwd, grp, syslog, select, _socket
0
1
0
0
2013-10-16T10:40:00.000
1
-0.197375
false
19,401,302
0
0
0
1
I am running SLC5 (RedHat 4 Linux). The distributed Python version is 2.4. I have installed Python 2.7 in addition manually (altinstall). Running in terminal mode (Runlevel 3), the key mapping in bash and the Python 2.4 interpreter are correct (backspace, key arrows, etc. are working fine). When running the Python 2.7 interpreter, the key mappings are wrong (Backspace = ^? instead of ^H; Ctrl-H is working fine) When running under gnome (Runlevel 5) in the gnome-terminal, the mapping is correct for Python 2.7. Any idea what I need to set/configure that the key mapping is correct for Python 2.7 in the terminal mode (RL3) ? Thanks very much ! Markus
Run terminal command as startup reacts different from manually (linux raspberry pi)
19,407,980
0
0
631
0
python,linux,terminal,raspberry-pi
What are you using to play the streams? Depending on how you boot up the second Raspberry it might not have started some daemons for audio/video playback?! You should (if you're not already doing) write a log (import logging ;)) and write a logfile which you can track for errors.
0
1
0
1
2013-10-16T14:42:00.000
2
0
false
19,406,444
0
0
0
2
Here's a short description of what I have: I have to raspberry pi's in a local net work. I one of them I have a .py script named watchdog.py that starts a stream and then uses a sshpass command to the other pi to display the video stream.It also has some signaling LEDs a some push buttons for control the problem is: If I open a terminal and run the watchdog.py script in the GUI everything runs as it should be. So I thought of running it as a service as boot and installed upstart and made it run as a service (successfully I think). The thing is. If I boot the pi and then press the button to start the streams,they wont play on the other Pi, the LEDs ligh up and all the buttons work. And even the CPU load behaves the same way, but i still don't video nor audio. I have thought of trying automatically open a terminal (LXterminal) widow and run the python scrip on that window. but I didn't want the streaming raspberry pi also booting into gui (tough I guess I would mind if that makes the whole thing work).This little thing i making the whole project useless.
Run terminal command as startup reacts different from manually (linux raspberry pi)
42,814,929
0
0
631
0
python,linux,terminal,raspberry-pi
answer moved from OP's question itself: I found a way that seems to work so far. instead of running the python script as a service I tried running it as cron job at reboot, and it worked. now it all works straight from reboot and I have Audio and video.
0
1
0
1
2013-10-16T14:42:00.000
2
0
false
19,406,444
0
0
0
2
Here's a short description of what I have: I have to raspberry pi's in a local net work. I one of them I have a .py script named watchdog.py that starts a stream and then uses a sshpass command to the other pi to display the video stream.It also has some signaling LEDs a some push buttons for control the problem is: If I open a terminal and run the watchdog.py script in the GUI everything runs as it should be. So I thought of running it as a service as boot and installed upstart and made it run as a service (successfully I think). The thing is. If I boot the pi and then press the button to start the streams,they wont play on the other Pi, the LEDs ligh up and all the buttons work. And even the CPU load behaves the same way, but i still don't video nor audio. I have thought of trying automatically open a terminal (LXterminal) widow and run the python scrip on that window. but I didn't want the streaming raspberry pi also booting into gui (tough I guess I would mind if that makes the whole thing work).This little thing i making the whole project useless.
How can I tell if Python setuptools is installed?
56,683,743
0
18
68,259
0
python,pip,setuptools
This will display the version of your setuptools if it is installed already $python -c "import sys; import setuptools; print(setuptools.version.__version__)"
0
1
0
0
2013-10-17T15:03:00.000
7
0
false
19,430,346
1
0
0
2
I'm writing a quick shell script to make it easier for some of our developers to run Fabric. (I'm also new to Python.) Part of installing Fabric is installing pip, and part of installing pip is installing setuptools. Is there any easy way to detect if setuptools is already installed? I'd like to make it possible to run the script multiple times, and it skip anything it's already done. As it stands now, if you run ez_setup.py twice in a row, you'll get a failure the second time. One idea I had was to look for the easy_install scripts under the /Scripts folder. I can guess at the Python root using sys.executable, and then swap off the executable name itself. But I'm looking for something a little more elegant (and perhaps cross-OS friendly). Any suggestions?
How can I tell if Python setuptools is installed?
62,062,115
0
18
68,259
0
python,pip,setuptools
Depends with the python version installed. you can try "pip list" or "pip3 list" and check for the setuptools and version installed.
0
1
0
0
2013-10-17T15:03:00.000
7
0
false
19,430,346
1
0
0
2
I'm writing a quick shell script to make it easier for some of our developers to run Fabric. (I'm also new to Python.) Part of installing Fabric is installing pip, and part of installing pip is installing setuptools. Is there any easy way to detect if setuptools is already installed? I'd like to make it possible to run the script multiple times, and it skip anything it's already done. As it stands now, if you run ez_setup.py twice in a row, you'll get a failure the second time. One idea I had was to look for the easy_install scripts under the /Scripts folder. I can guess at the Python root using sys.executable, and then swap off the executable name itself. But I'm looking for something a little more elegant (and perhaps cross-OS friendly). Any suggestions?
Modifying a crontab from a cron job
19,448,431
2
2
1,397
0
python,linux,ubuntu,cron
The GPL is not anti-commercial. python-crontab can be used in commercial products and services. You must only follow the copy-left rules witch state that the actual code itself can't be made proprietary. You can sell it as much as you like, and as the author I encourage you to make money from my work. Besides that error, it doesn't look like your problem requires python-crontab anyway. You could just open the files yourself and if that doesn't work, it was never going to work with python-crontab anyway.
0
1
0
1
2013-10-17T22:07:00.000
1
0.379949
false
19,438,160
0
0
0
1
I have a Python script that runs in several modes. One of those modes monitors certain files, and if those files have been modified, the script restores them. The way I do this is to run the script every minute via cron. Another cron job exists (actually the same script called with a different argument) to remove the script from the crontab when the scheduled time has elapsed. Initially, I was attempting to work with a crontab in /etc/cron.d. The script behaves as expected if executed on the command line, but does not edit the crontab when it is run from cron. I then switched to writing a temporary file and executing crontab tempfile (via subprocess.Popen) from the script. This doesn't work either, as the crontab is simply not created. Executing crontab tempfile from the commandline and using the temporary file created by the script works as expected. I can't use the python-crontab library as this is a commercial project and that library is GPLed. Are there any inherent limitations in cron that prevent either approach from working?
Why does my virtualenv inherit the system's old environment variables?
20,532,631
1
1
410
0
python,environment-variables,virtualenv
I discovered that the reason my virtual environment's environment variables were keeping their previous values was because I was still in the same terminal session. Restarting my terminal fixed the issue.
0
1
0
0
2013-10-17T22:43:00.000
1
1.2
true
19,438,580
1
0
0
1
When I created my virtual environment, it inherited all of the environment variables that were currently on my Windows machine. I have since changed many of those variables, and my virtual environment is now stuck with the old values. How can I change the environment variables within my virtual environment?
IntelliJ IDEA - unix python virtualenv on WIndows
19,448,864
0
1
426
0
python,windows-7,intellij-idea,virtualenv,python-2.6
Just install an appropriate python and virtualenv for that python directly on the windows 7 machine.
0
1
0
0
2013-10-18T11:26:00.000
2
0
false
19,448,553
1
0
0
2
I have Python application and virtualenv for it. I run it on Debian virtual machine. Is it possible to configure IntelliJ to start application and use IntelliJ debug tools? The problem is how to use virtualenv for debian in Windows 7 system.
IntelliJ IDEA - unix python virtualenv on WIndows
19,809,928
0
1
426
0
python,windows-7,intellij-idea,virtualenv,python-2.6
I solved it. If connect with my virtual machine by remote debug tool. I add one line with IntellJ/PyCharm generate to entry point of paster script. Before debug i run script (using IntelliJ remote tool) with run application on virtual machine.
0
1
0
0
2013-10-18T11:26:00.000
2
0
false
19,448,553
1
0
0
2
I have Python application and virtualenv for it. I run it on Debian virtual machine. Is it possible to configure IntelliJ to start application and use IntelliJ debug tools? The problem is how to use virtualenv for debian in Windows 7 system.
Hierarchy in Google App Engine NDB
19,454,685
5
3
1,057
0
python,google-app-engine
If you use the ancestor in the key you will create a big entity group (assuming a single root to the tree/hierarchy) which may in fact not be what you want from a write performance point of view. Also a deep hierarchy can mean very big keys. If you want to move nodes around using ancestor keys, you have to delete and recreate the entire child hierarchy of keys, where as storing the parent in the node (or the children keys in the parent) means you just store different keys in properties. If you normally walk down the hierarchy (say url traversal) you may find it more efficient to just store the childrens keys in a list in the parent, assuming each level is not going to have too many immediate children, as well as storing the parent key in the child. I would examine your actual requirements in detail before deciding which way to go.
0
1
0
0
2013-10-18T14:28:00.000
2
1.2
true
19,452,172
0
0
1
1
I'm trying to store a hierarchy in NDB and I'm confused about if I should use just the 'parent' parameter while constructing the keys to new entities or should I include an extra property in my models to hold the parent key?
Issue creating project with mezzanine - shared hosting
21,524,630
0
0
265
0
python,shared-hosting,mezzanine
Now supporting with Mezzanine 3.x
0
1
0
0
2013-10-19T10:44:00.000
2
0
false
19,465,158
0
0
1
1
I'm trying to use Mezzanine cms in a shared hosting at 1and1. I installed a recent python version 3.3.2. setup works well but when i try to create a project I got the following error message: ~/Mezzanine-1.4.16 > mezzanine-project blog Traceback (most recent call last): File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/bin/mezzanine-project", line 9, in load_entry_point('Mezzanine==1.4.16', 'console_scripts', 'mezzanine-project')() File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/lib/python3.3/site-packages/distribute-0.6.49-py3.3.egg/pkg_resources.py", line 345, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/lib/python3.3/site-packages/distribute-0.6.49-py3.3.egg/pkg_resources.py", line 2382, in load_entry_point return ep.load() File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/lib/python3.3/site-packages/distribute-0.6.49-py3.3.egg/pkg_resources.py", line 2088, in load entry = __import__(self.module_name, globals(),globals(), ['__name__']) File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/lib/python3.3/site-packages/Mezzanine-1.4.16-py3.3.egg/mezzanine/bin/mezzanine_project.py", line 9, in from mezzanine.utils.importing import path_for_import File "/kunden/homepages/x/dxxxxxxx/htdocs/custom/lib/python3.3/site-packages/Mezzanine-1.4.16-py3.3.egg/mezzanine/utils/importing.py", line 23 except (ValueError, ImportError, AttributeError), e: ^ SyntaxError: invalid syntax Any thoughts on how to fix this ? thank you.
How to make work in terminal.app on mac?
19,501,157
0
0
437
0
macos,terminal-emulator,python-mode,jedi-vim
Solved. I have "set paste" and it disabled all user-defined key mappings under insert mode. It didn't influence GUI macvim since pasted mode was unnecessary for GUI editors.
0
1
0
1
2013-10-20T02:48:00.000
1
0
false
19,473,378
0
0
0
1
I want to use python-mode and jedi for autocompletion in Vim for python. However under my environment (vim 7.3 in terminal.app on OSX 10.8), I just cannot have the key-combination work. I read many related articles and knows that it is because terminal.app interpret as and I tried to use inoremap to change it but it does not work. Anyone has similar problem and figured out ideal solutions? Thx! (In macvim with Gui there is no such problem, but I'd prefer run vim in terminal. I tried iterm2 but it also suffers.)
Does ndb.delete_multi with all keys from the same parent count as a single update to the entity group?
19,514,013
2
0
212
0
python,google-app-engine,app-engine-ndb
Inside the same transaction you can delete 200 entities/keys in one go. The 1/second limit (more likely 5/second) should be read as: How often can I start (and commit) an independent transaction on an entity group or x-group. T.i. because each transaction needs a lock on the root element you're commiting.
0
1
0
0
2013-10-20T11:48:00.000
1
1.2
true
19,476,982
0
0
0
1
I'm deciding whether or not to include a "fetch 200/delete 200" routine of a pipeline inside a transaction. If not included and the request/instance dies abruptly, the fetched entities would be lost. Since with xg=True, the entity group limit is 5, the 200 entities need to have the same parent to be included in the transaction. If delete_multi with 200 keys, count as 200 simultaneous updates to the entity group, the routine might fail, as the preferred limit to entity groups is 1/second. When those 200 entities are deleted with ndb.delete_multi, does it count as 1 updates or 200 updates to the entity group?
How to convert python code (.py) to an app on mac osx
19,920,734
3
1
4,091
0
python,macos,py2app,dmg
You can use py2app. It makes a standard app. All it needs is a python script and setup.py.
0
1
0
0
2013-10-21T06:06:00.000
2
1.2
true
19,487,291
1
0
0
1
I am making an app in python, which is able to open different file types. This code is running fine on eclipse while passing filename which I want to open and configuration file as arguments respectively selectedFileName=(sys.argv)[1] cfgFile=(sys.argv)[2]. Now I converted this into application by using py2app. So, the issue is how to deal with arguments, as different file types need to be open through app and this app also needs configuration file while processing. Through py2app, in terminal passing this command open -a myapp.app selectedFileName config.cfg opens the file as expected. But, What I want is to directly open file of any extension without the use of terminal. Is openwith for opening file possible in this case, then how?. What changes I have to make in code for passing arguments for both? I also want to distribute this app to others.
Get live stdout from gevent-subprocess?
19,500,240
3
5
3,089
0
python,subprocess,stdout,gevent
I solved this using a little hack. Just flush Pythons line-buffer w/ self.stream.flush() and a helper class whenever a line is written to stdout.
0
1
0
0
2013-10-21T14:43:00.000
3
1.2
true
19,497,587
0
0
0
1
I'm trying to get the stdout of a process via POPEN as soon as it's there. With gevent 1.0 readline() and read() still block process and wait for process to finish. Any clues? And yes, I searched high and low for a simple solution. It has to be possible without threading, right?
python write to a file that is open for reading by another program (TCL)
19,499,632
0
1
1,515
0
python,tcl,file-access
I tested writes and reads with Python and TCL and it looks like python will write when TCL has a file open for reading. TCL can write when python has a file open for reading.
0
1
0
0
2013-10-21T15:07:00.000
1
0
false
19,498,155
1
0
0
1
I have to concurrently run TCL and Python scripts which access the same files. I have decided to restrict each program so that they have exclusive write access to exactly one file. Each program has read access to all files (say two programs and two files). I don't care about dirty reads (ie reading a partially finished write). I just want to know what will happen in the following two cases: a programs tries to open a file for writing when another program has it open for reading. a program tries to open a file for reading while another program has it open for writing. I guess I am concerned that the write will fail if the other program has the file open (even if it is only open in read mode). I am running in windows with a single Python thread and a TCL program called from Python on subprocess.
RedirectRoute in Google App Engine and url arguments
19,500,983
1
1
156
0
python,google-app-engine,webapp2
A RedirectRoute will issue a HTTP redirect telling the browser to go to the new URL, then the browser will make a new request at that URL. How this is implemented is that two routes are created - your original route, and one for redirecting. So, in your case, a route with /do/some/<action:.*>/ would be created that redirects to /do/some/<action.*>. However, I think your route actually will be checked first (not positive, sorry), so it would just always fire. I would modify it to not match slashes, if that's okay. Luckily, that's the default behaviour if you omit the regex, so just /do/some/<action:> should work!
0
1
0
0
2013-10-21T15:48:00.000
1
0.197375
false
19,499,079
0
0
1
1
I have a RESTful API like /do/some/<action:.*> so my app with get <action> and run it. My question is, if I use RedirectRoute and strict_slash=True, will my app keep getting <action> as argument or will it start getting <action>/ (notice the / at the end)? EDIT: I'm using webapp2
How can I get the current read position in a win32file file handle?
19,503,816
0
2
1,118
0
python,pywin32
Yes, SetFilePointer is less than obvious. The current file position is also found using SetFilePointer, specify a move method of FILE_CURRENT and a distance of zero.
0
1
0
0
2013-10-21T20:07:00.000
2
0
false
19,503,736
1
0
0
1
I am trying to use python to create a tail-like utility that can read from a file that is actively open and being written to in another process. It needs to work on windows so I am having to use the win32file module. I will need to open this file and seek to a previously saved location. I have found the SetFilePointer function which will do the moving but, when I get done, I need to store the position of the read pointer for a future iteration. There does not appear to be a function that will give them the position of the read pointer. The naming convention on these functions is not always intuitive so maybe I'm just missing it.
How to avoid hitting App Engines free limits with tons of writes?
19,508,340
0
0
49
0
python,google-app-engine
Pack more data into an entity, and arrange to not index any fields you're never going to query on. That may interfere with querying your logs, but if writes predominate, pack more into each write, saving writes and index updates. You'll pay for it later when querying, but if queries are infrequent, it may be a net win.
0
1
0
0
2013-10-22T02:12:00.000
1
1.2
true
19,507,887
0
0
1
1
I'm trying to handle remote logging with app engine, but I find just by myself I'm exceeding the daily write limit. Are there any datastore tricks I can use to consume less of my write quota while posting data to the server constantly?
how to make python script executable when click on the file
22,898,338
1
2
12,507
0
python
It's Nautilus's fault. Open Nautilus (the file manager), go to Menu > Preferences. Select the "Behaviour" section. On the field titled "Executable text files", select the option "Execute executable text files when opened".
0
1
0
1
2013-10-22T05:47:00.000
7
0.028564
false
19,509,911
0
0
0
6
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
how to make python script executable when click on the file
19,510,082
2
2
12,507
0
python
Add #!/usr/bin/env python at the very beginning of file. Make chmod u+x filename.py Change your extension from .py to .sh, so your linux distro's UI will recognize it as shell script and try to execute.
0
1
0
1
2013-10-22T05:47:00.000
7
0.057081
false
19,509,911
0
0
0
6
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
how to make python script executable when click on the file
19,510,040
0
2
12,507
0
python
If you don't have any specific version requirement then using first line as #!/usr/bin/env python will be more efficient and give the execute permission chmod u+x test.py
0
1
0
1
2013-10-22T05:47:00.000
7
0
false
19,509,911
0
0
0
6
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
how to make python script executable when click on the file
19,509,956
5
2
12,507
0
python
Add #!/bin/python as the very first line of your file. Or, if you don't know where your python executable is, type which python in a terminal; then copy the result of that and put it after the #!. Change the permissions of the file so that its executable chmod u+x test.py i try but it still open back as gedit Right click on the file in your gnome file browser or desktop. Select Properties Go to Open with and choose Python. If you don't see python in the list, add the command. Just type python in the command to be added.
0
1
0
1
2013-10-22T05:47:00.000
7
0.141893
false
19,509,911
0
0
0
6
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
how to make python script executable when click on the file
55,925,012
0
2
12,507
0
python
I use raspibian os (Linux) Add #!/usr/bin/python as the first line of the file.py right click file >> open with >> chose customize >> custom command line >> type python3 execute file with double click is working
0
1
0
1
2013-10-22T05:47:00.000
7
0
false
19,509,911
0
0
0
6
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
how to make python script executable when click on the file
19,509,975
0
2
12,507
0
python
Add #!/usr/bin/python as the first line of the file and set the permission to executable chmod 755 yourfile.
0
1
0
1
2013-10-22T05:47:00.000
7
0
false
19,509,911
0
0
0
6
I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. How i going to do this in my fedora machine.
Is Grok inactive?
19,538,042
1
1
141
0
python,zope,grok
No, the project has not been deprecated. Like many open source software projects there is a natural cycle in interest and activity, with the only difference being the speed in which the cycle progresses. Deprecation is an explicit choice by the maintainers; no such choice has been made. It's just that most interest in the project has moved on elsewhere.
0
1
0
0
2013-10-22T22:32:00.000
1
0.197375
false
19,529,573
0
0
0
1
Since the last version is 1.9, released on 2011, but the documentation only covers from 1.0 to 1.5. Also Windows Installers aren't available. It seems that there's poor activity around the framework, also in the mailing list and IRC channel. Edited the title because of the confusions. Thanks to everyone for the replies.
How to run python script on terminal (ubuntu)?
28,650,632
-8
15
205,865
0
python,linux,ubuntu
First create the file you want, with any editor like vi r gedit. And save with. Py extension.In that the first line should be !/usr/bin/env python
0
1
0
1
2013-10-22T23:17:00.000
5
-1
false
19,530,015
0
0
0
3
I'm new with python, I've been learning for a few weeks. However now I've just changed my OS and I'm now using ubuntu and I can't run any script on my terminal. I made sure to have the #!/usr/bin/env python but when I go to the terminal and type, for example python test.py the terminal shows an error message like this python: can't open file 'test.py': [Errno 2] No such file or directory what do I do? I must save the file in any specific folder to make it run on terminal?
How to run python script on terminal (ubuntu)?
42,282,440
0
15
205,865
0
python,linux,ubuntu
Save your python file in a spot where you will be able to find it again. Then navigate to that spot using the command line (cd /home/[profile]/spot/you/saved/file) or go to that location with the file browser. If you use the latter, right click and select "Open In Terminal." When the terminal opens, type "sudo chmod +x Yourfilename." After entering your password, type "python ./Yourfilename" which will open your python file in the command line. Hope this helps! Running Linux Mint
0
1
0
1
2013-10-22T23:17:00.000
5
0
false
19,530,015
0
0
0
3
I'm new with python, I've been learning for a few weeks. However now I've just changed my OS and I'm now using ubuntu and I can't run any script on my terminal. I made sure to have the #!/usr/bin/env python but when I go to the terminal and type, for example python test.py the terminal shows an error message like this python: can't open file 'test.py': [Errno 2] No such file or directory what do I do? I must save the file in any specific folder to make it run on terminal?
How to run python script on terminal (ubuntu)?
61,037,599
0
15
205,865
0
python,linux,ubuntu
Sorry, Im a newbie myself and I had this issue: ./hello.py: line 1: syntax error near unexpected token "Hello World"' ./hello.py: line 1:print("Hello World")' I added the file header for the python 'deal' as #!/usr/bin/python Then simple executed the program with './hello.py'
0
1
0
1
2013-10-22T23:17:00.000
5
0
false
19,530,015
0
0
0
3
I'm new with python, I've been learning for a few weeks. However now I've just changed my OS and I'm now using ubuntu and I can't run any script on my terminal. I made sure to have the #!/usr/bin/env python but when I go to the terminal and type, for example python test.py the terminal shows an error message like this python: can't open file 'test.py': [Errno 2] No such file or directory what do I do? I must save the file in any specific folder to make it run on terminal?
Distributed Networked Applications (Python, Celery, 0MQ, etc)
20,719,307
0
0
299
0
python,celery,zeromq,pyinstaller,pyro
if the individual tasks dont need to communicate to other tasks then use Celery, otherwise Pyro as it allows communication between tasks/objects running parallely on worker nodes.
0
1
0
0
2013-10-23T03:51:00.000
1
1.2
true
19,532,445
0
0
0
1
Hi Everyone, I have been developing with python for about a year. Now i have a need to develop distributed applications which communicate with each other. I do not have an idea which modulue will be the best to learn, so i need your help and advise on this. My app needs are, Client Server must be able to communicate and exchange data with each other. Tasks Needs to be scheduled on server and client. Kind of Cron like, no need for auto consuming stuff. I would like to be able to complie everything into a exe,app,package to support Win,Mac,Linux. Thin Clients or workers, and fat servers My issues are as follows. Nearly everything i see is going towards the web application (Djano, Celery). I need to have a daemon worker running, and thats it. But if i want to use celery, then i would need to have the code in py files and running, which i am not so keen on. Not to mention pyinstaller does not support the packaging I have researched quite a bit into it, and which module is best i am not sure. But i have sort of narrowed down to celery as the best bet. But i am thinking of ZeroMQ or Pyro as the compiling part later on i am not too sure. Please do advise, Kumar