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
APPDATA is not returned in Python executed via CGI
11,246,816
1
1
496
0
python,apache,cgi,nltk,appdata
%APPDATA% is a special variable that expands to the "Application Data" directory of the user who expands the variable (i.e., who runs a script). Apache is not running as you, so it has no business knowing about your APPDATA directory. You should either hard-code the relevant path into your script, or replace it with a path relative to the location of the script, e.g., r'..\data\nltk_data'. If you really need to, you can recover the absolute location of your script by looking at __file__.
0
1
0
0
2012-06-27T04:16:00.000
3
0.066568
false
11,219,319
0
0
1
1
I'm using Python with the NLTK toolkit in Apache via CGI. The toolkit need to know the APPDATA directory, but when executed in the server, the os.environ not lists theAPPDATA. When I execute a simple print os.envrion in console, APPDATA is present, but not when executed via CGI in the web server. What is going on? How can I solve this? I'm new to Python and I'm just learning it yet.
CentOS 5.8 dependencies on Python 2.4?
11,251,911
1
0
1,419
0
python,centos
If python2.7 is available on Yum, you should use that: the package management on large distros (redhat, ubuntu, debian, fedora ) takes care of maintaining parallel Python installs for you which won't conflict with each other. This option should keep your system "/usr/bin/python¬ file pointing to Python2.4 and give you another python2.7 binary. Otherwise, if you choose to build it from source, pick another prefix - /opt - (not even /usr/local will be quite safe) for building it. You don't need to know exactly which system parts depend on Python 2.4 - just rest assured it will crash very hard and unpredictably if you try to modify the system Python itself.
0
1
0
1
2012-06-27T10:49:00.000
1
1.2
true
11,224,517
0
0
0
1
I have a CentOS 5.8 server and am planning to install a later version of python (presumably 2.7). I have heard a lot of mention that CentOS relies quite heavily on 2.4 for many admin features etc. I'm trying to determine exactly what these features are (and whether I would actually be using them) so that I can decide whether to update python through yum or build from source. Can anyone give me some more detailed information on what CentOS features have dependencies on Python 2.4.
Getting mount type information in python on OSX
11,228,033
2
1
813
0
python,macos,mount
Have a look at the diskutil(8) and hdiutil(1) tools.
0
1
0
0
2012-06-27T13:40:00.000
1
1.2
true
11,227,579
0
0
0
1
Is there a way in which I can get some information about the mounts I have in the folder /Volumes in OSX? I want to be able to tell the difference between disk images like dmgs and other types, like hard disks or network mounts. I tried parsing the output of mount -v and looking if read-only is in the line but I doubt that's a particularly accurate way of telling, and also not a good method either. Is there any module or method that will give me this information?
Where to store the configuration files of python applications on Windows
11,228,733
2
10
4,707
0
python,windows
On Linux, it is common to store the configuration file in the users home directory, for instance ~/.myprogramrc. On windows Vista and up, users have a home directory as well (/Users/username) and a would recommend storing your settings there in a subfolder (/Users/useranem/myprogram). Storing the settings in the application folder will generate UAC warnings. On Windows XP, users do not have a home folder. Some programs make the choice of putting configuration in the 'My Documents' folder which I guess is as good a place as any.
0
1
0
0
2012-06-27T14:35:00.000
3
0.132549
false
11,228,645
1
0
0
1
I have a python program that must work on Windows and Linux. There are some configuration options I normally store in a file, in a subdirectory of the program's directory. For Windows, I converted it to exe and created an Installer for it. And now I have the problem of dealing with the config file. What is the best place to save the configuration file? I have read that for Windows os.environ['APPDATA']+'myAppName' is the path that must be used. Is it correct? Is it standard? Will it work in all versions of Windows at least from XP (and at least in English and Spanish)? PD: I am not interested in using ConfigParser. Config file is in my own format and I have working code for reading/writing from it.
Removing python
11,239,806
1
0
289
0
python
Most of the code written in Ubuntu is written in Python. One should avoid removing system dependencies at any time. You can do sudo apt-get install python but rest of the programs are probably gone; even though you install them manually, you can experience random bugs, system failures. I think you should just re-install ubuntu
0
1
0
0
2012-06-28T06:55:00.000
1
1.2
true
11,239,467
1
0
0
1
I removed python from my computer to be reinstalled. However after removing it, many services has gone from my Ubuntu 10.04. (e.g. mozilla, Ubuntu Software Center and many applications from System tab.) How can I get back all of them? Thanks a lot..
store openid user in cookie google appengine
11,249,560
1
0
191
0
python,google-app-engine,cookies,openid
users.get_current_user() is actually reading the cookies so you don't need to do anything more to optimize it (you can easily verify it by deleting your cookies and then refreshing the page). Unless you want to store more information and have access to them without accessing the datastore on every request.
0
1
0
0
2012-06-28T16:47:00.000
1
1.2
true
11,249,313
0
0
1
1
I am using OpenID as a login system for a google appengine website and I right now for every website I am just passing the user info to every page using user = users.get_current_user() Would using a cookie to do this be more efficient? (I know if would be easier that putting that in every single webpage) and is these any special way to do it with google appengine? I already have a cookie counting visits but I would image it'll be a little different. Update: Could I do self.user = users.get_current_user() as a global variable and then pass in user=self.user on every page to have access to that variable? Thanks!
How to check if Google App Engine python27 runs thread safe mode or not?
11,259,344
1
0
268
0
python,multithreading,google-app-engine,python-2.7
You can't have "some thread safe and some not thread safe". That's impossible. If some code is not thread safe, then none of the code is thread safe. That's just how thread safety works.
0
1
0
0
2012-06-29T08:48:00.000
2
0.099668
false
11,258,710
1
0
0
1
Please help how it is possible to detect if python27 runtime is run in thread safe mode or not for code? For example to notify that module is not compatible or apply threading code if required. I want to port some code to python27 as thread safe and some as not thread safe but not understand how it works in Google App Engine.
long running CPU intensive python script sent to sleep by scheduler
11,259,189
2
1
376
0
python,ubuntu,sysadmin,nice
The scheduler will only put your process on hold if there is another process ready to run. If you have no other processes which hog up the CPU, your process will be running most of the time. The scheduler does not put your process to sleep just because it feels like it. My guess is that there is some reason your process is not runnable, e.g. it is blocking and waiting for I/O or data.
0
1
0
0
2012-06-29T09:13:00.000
1
1.2
true
11,259,076
0
0
0
1
I have written a data munging script that is very CPU intensive. It has been running for a few days now, but now (thanks to trace messages sent to the console), I can see that it is not working (actually, has not been working for the last 10 hours or so. When I run top, I notice that the process is either sleeping (S) or in uninterreptable sleep (D). This is wasting a lot of time. I used sudo renice -10 PID to change the process's nice value, and after running for a short while, I notice that the process has gone back to sleep again. My question(s): Is there anything I can do to FORCE the script to run until it finishes (if even it means the machine is unusable until the end of the script? Is there a yield command I can use in Python, which allows me to periodically pass control to other process/threads to stop the scheduler from trying to put my script to sleep?. I am using python 2.7.x on Ubuntu 10.0.4
what is the best way to do bidirectional IPC between a long-running c process and python?
11,263,176
1
3
1,766
0
python,c,ipc,protocol-buffers,thrift
My default choice would be to use normal sockets communicating over localhost. Sockets are a well understood language and platform neutral API that tend to perform very well. They also the advantage of not tieing you to two processes on the same box which can be advantageous in many situations.
0
1
0
0
2012-06-29T13:48:00.000
2
0.099668
false
11,262,984
0
0
0
1
I have an existing C process that can take one text input and produce a single image file. This C process has a high setup/teardown cost due to it's interface with an external system. Once the setup/teardown has occured the actual production of image from text is almost instantaneous. My plan is to daemonize the C process, so it will receive text and produce image files in an infinite loop, while maintaining a connection to the external system. I will also write a small client program in python, which will interface with the daemon to send text/receive the image. The target OS is unix. The question is, what is the best way to do bidirectional IPC between python/C in this case? Should I just open a unix domain socket and send packed structs back and forth, or should I look at something like Apache Thrift or protobuf? UPDATE: Just going to keep it simple, and open a unix domain socket
Escaping arbitrary blocks of code
11,270,699
3
2
161
0
python,python-3.x
There are a few different options here. First, start with jdi's suggestion of using multiprocessing. It may be that Windows process creation isn't actually expensive enough to break your use case. If it actually is a problem, what I'd personally do is use Virtual PC, or even User Mode Linux, to just run the same code in another OS, where process creation is cheap. You get a free sandbox out of that, as well. If you don't want to do that, jdi's suggestion of processes pools is a bit more work, but should work well as long as you don't have to kill processes very often. If you really do want everything to be threads, you can do so, as long as you can restrict the way the jobs are written. If the jobs can always be cleanly unwound, you can kill them just by raising an exception. Of course they also have to not catch the specific exception you choose to raise. Obviously neither of these conditions is realistic as a general-purpose solution, but for your use case, it may be fine. The key is to make sure your code evolver never inserts any manual resource-management statements (like opening and closing a file); only with statements. (Alternatively, insert the open and close, but inside a try/finally.) And that's probably a good idea even if you're not doing things this way, because spinning off hundreds of processes that, e.g., each leak as many file handles as they can until they either time out or hit the file limit would slow your machine to a crawl. If you can restrict the code generator/evolver even further, you could use some form of cooperative threading (e.g., greenlets), which makes things even nicer. Finally, you could switch from CPython to a different Python implementation that can run multiple interpreter instances in a single process. I don't know whether jython or IronPython can do so. PyPy can do that, and also has a restricted-environment sandbox, but unfortunately I think both of those—and Python 3.x support—are not-ready-for-prime-time features, which means you either have to get a special build of PyPy (probably without the JIT optimizer), or build it yourself. This might be the best long-term solution, but it's probably not what you want today.
0
1
0
0
2012-06-29T23:07:00.000
2
0.291313
false
11,270,021
1
0
0
1
My script accepts arbitrary-length and -content strings of Python code, then runs them inside exec() statements. If the time to run the arbitrary code passes over some predetermined limit, then the exec() statement needs to exit and a boolean flag needs to be set to indicate that a premature exit has occurred. How can this be accomplished? Additional information These pieces of code will be running in parallel in numerous threads (or at least as parallel as you can get with the GIL). If there is an alternative method in another language, I am willing to try it out. I plan on cleaning the code to prevent access to anything that might accidentally damage my system (file and system access, import statements, nested calls to exec() or eval(), etc.). Options I've considered Since the exec() statements are running in threads, use a poison pill to kill the thread. Unfortunately, I've read that poison pills do not work for all cases. Running the exec() statements inside processes, then using process.terminate() to kill everything. But I'm running on Windows and I've read that process creation can be expensive. It also complicates communication with the code that's managing all of this. Allowing only pre-written functions inside the exec() statements and having those functions periodically check for an exit flag then perform clean-up as necessary. This is complicated, time-consuming, and there are too many corner-cases to consider; I am looking for a simpler solution. I know this is a bit of an oddball question that deserves a "Why would you ever want to allow arbitrary code to run in an exec() statement?" type of response. I'm trying my hand at a bit of self-evolving code. This is my major stumbling block at the moment: if you allow your code to do almost anything, then it can potentially hang forever. How do you regain control and stop it when it does?
use standard datastore index or build my own
11,270,908
0
0
82
1
python,google-app-engine,indexing,google-cloud-datastore
I'd suggest using pre-existing code and building around that in stead of re-inventing the wheel.
0
1
0
0
2012-06-30T00:18:00.000
2
0
false
11,270,434
0
0
1
1
I am running a webapp on google appengine with python and my app lets users post topics and respond to them and the website is basically a collection of these posts categorized onto different pages. Now I only have around 200 posts and 30 visitors a day right now but that is already taking up nearly 20% of my reads and 10% of my writes with the datastore. I am wondering if it is more efficient to use the google app engine's built in get_by_id() function to retrieve posts by their IDs or if it is better to build my own. For some of the queries I will simply have to use GQL or the built in query language because they are retrieved on more than just and ID but I wanted to see which was better. Thanks!
How to configure a virtual environment that doesn't require sudo?
11,278,661
0
2
134
0
python,pip,easy-install
Make sure you use a recent version of virtualenv itself, the latest at the time of writing is 1.7.2. Old versions required the use of -E switch, to install into the virtual environment.
0
1
0
0
2012-06-30T13:05:00.000
3
0
false
11,274,297
1
0
0
1
In my Ubuntu 12.04 machine, the installation of pip requirements is asking me for sudo permission every time it attempts to install. How would I override this, as this is terrible for my working environment to install things globally instead of inside the venv? Note: I did not setup the venv using sudo.
Is it feasible to run multiple processeses on a Heroku dyno?
11,282,872
4
10
2,842
0
python,heroku,subprocess,worker
On the newer Cedar stack, there are no issues with spawning multiple processes. Each dyno is a virtual machine and has no particular limitations except in memory and CPU usage (about 512 MB of memory, I think, and 1 CPU core). Following the newer installation instructions for some stacks such as Python will result in a configuration with multiple (web server) processes out of the box. Software installed on web dynos may vary depending on what buildpack you are using; if your subprocesses need special software then you may have to either bundle it with your application or (better) roll your own buildpack. At this point I would normally remind you that running asynchronous tasks on worker dynos instead of web dynos, with a proper task queue system, is strongly encouraged, but it sounds like you know that already. Do keep in mind that accounts with only one web dyno (typically this means, "free" accounts) will have that dyno spun down after an hour or so of not receiving any web requests, and that any background processes running on the dyno at that time will necessarily be killed. Accounts with multiple web dynos are not subject to this restriction.
0
1
0
0
2012-07-01T04:15:00.000
1
1.2
true
11,279,527
0
0
1
1
I am aware of the memory limitations of the Heroku platform, and I know that it is far more scalable to separate an app into web and worker dynos. However, I still would like to run asynchronous tasks alongside the web process for testing purposes. Dynos are costly and I would like to prototype on the free instance that Heroku provides. Are there any issues with spawning a new job as a process or subprocess in the same dyno as a web process?
deploying a Python application from a PHP developer
11,287,479
1
1
230
0
python,deployment
Copy the directory containing the virtualenv. Exclude all virtualenv-generated files. On the destination machine, create a virtualenv over the directory. source bin/activate pip install -r requirements.txt The first step is simplified if you use version control; you simply clone (Mercurial or Git) or checkout (Subversion) the code. All the virtualenv-generated files should have been in the appropriate ignore file. (.hgignore, .gitignore, .svnignore).
0
1
0
0
2012-07-02T03:23:00.000
1
0.197375
false
11,287,466
1
0
0
1
I'm a little confused on the deployment process for Python. Let's say you create a brand new project with virtualenv source bin/activate pip install a few libraries write a simple hello world app pip freeze the dependencies When I deploy this code into a machine, do I need first make sure the machine is sourced before installing dependencies? I don't mean to sound like a total noob but in the PHP world, I don't have to worry about this because it's already part of the project. All the dependencies are registered with the autoloader in place. The steps would be: rsync the files (or any other method) source bin/activate pip install the dependencies from the pip freeze output file It feels awkward, or just wrong and very error prone. What are the correct steps to make? I've searched around but it seems many tutorials/articles make an assumption that anyone reading the article has past python experience (imo). UPDATE: I've should have mentioned that I'm trying to understand how it hooks up with Apache.
Installing lxml in virtualenv for windows
23,508,071
0
6
2,061
0
python,lxml,virtualenv,pip
Just wanted to add that emeraldo.cs's answer is correct, but you also have to copy the lxml related files that exist in the site-packages root. Once all the files are copied, pip will think it's installed.
0
1
0
0
2012-07-02T03:48:00.000
3
0
false
11,287,585
1
0
0
1
I've recently started using virtualenv, and would like to install lxml in this isolated environment. Normally I would use the windows binary installer, but I want to use lxml in this virtualenv (not globally). Pip install does not work for lxml, so I'm at a loss for what I can do. I've read that creating symlinks may work, although I unfamiliar with how symlinks work and what files I should be creating them for. Does anyone else know of any methods to install lxml in a virtualenv on Windows? If creating symlinks is the only method that works I'm definitely willing to learn if someone can point me in the right direction.
In Macvim with +python3 supported, which command should I use to execute the current file itself?
11,288,495
3
0
428
0
python,vim,macvim
For Python 3, just simply execute :!python3 % Furthermore, you might also want to map it to a hotkey in your settings, like what I did: noremap <D-r> <esc>:w<CR>:!python3 %<CR> So that you can just press Command+r to execute the current code with Python 3 anytime (it will be saved automatically.
0
1
0
0
2012-07-02T04:40:00.000
2
1.2
true
11,287,862
1
0
0
1
I just set up IDE env for Python 3. I was wondering how I can run the file being currently edited in vim. I remembered that the command was ":python %", but it did not work for Python 3. Thank you very much.
Why is the argument of os.umask() inverted? (umask 0o000 makes chmod 0o777)
11,294,312
12
12
5,228
0
python,unix,filesystems,chmod,umask
There is no real inconsistency, as the relation between umask and chmod can purely be written down with equations. Apparently, umask sets the opposite of chmod, it was created like this back in the old days. Example: 022 (the default usual umask) creates 755. It works like this: 7 - 0 = 7 becomes the first byte 7 - 2 = 5 becomes the second and third bytes Using this example, umask 777 creates a file with chmod 000, umask 112 will be equal to chmod 664. As far as I know, this happened because the umask command was originally created to indicate what permission bits the file will NOT have after it's created (hence the invertion). While it could be annoying, it's really not hard to get used to it. Just think how you would chmod your files, and subtract the byte you want from 7, and you will get the umask value. Or, when you are at the IDE, writing your code, don't use umask, but rather create the file (with the default umask of course) and then use, in Python, os.chmod() instead.
0
1
0
0
2012-07-02T12:52:00.000
1
1.2
true
11,294,077
0
0
0
1
In most places, permissions are defined as an octal number in the format of 0777. But UNIX's umask command (thus os.umask()) needs 0o000 to produce the permission bits of 0o777 and 0o022 equals to 0o755 in my understanding. I heard that UNIX's umask is inverted for some reason and I do not understand the reason behind it. Could someone please explain this inconsistancy?
"python" only runs from command prompt as Admin
11,296,830
2
1
2,992
0
python,cmd
To append your path with python directory: path=%PATH$;c:\Python27 Run as normal user. You should also double check that c:\python27\python.exe actually exists.
0
1
0
0
2012-07-02T15:23:00.000
3
1.2
true
11,296,583
0
0
0
3
I'm on Windows 7 and if I type "python" in the command prompt as my regular user, I get the old, "'python' is not recognized as an internal or external command, operable program or batch file." but if I open the prompt as the administrator, python initiates like it should. The very first thing I did was edit the PATH variables through Control Panel, which seemed to add the environment variable, but there's a disconnect between doing this and cmd recognizing that I've done it. I have changed the permissions on the Python27 folder to allow full access to all users, I've tried adding a pythonexe variable and add that to the PATH, as another StackOverflow question suggested. When I type PATH = C:\Python27 into cmd as a regular user, that also wont work. and if I type in set PATH, "C:\Python27;" is in the returned line. I'm fairly certain it's a permission problem, which is the only reason I've re-posted my own version of this age old question. How do I run Python, given this error and these circumstances?
"python" only runs from command prompt as Admin
24,021,057
1
1
2,992
0
python,cmd
So, one of the things I noticed when I had that problem is that the USERNAME environment variable was only set to system which is the administrator environment variable. I simply looked up the username in the regular command prompt, using echo %USERNAME% and appended a semicolon and the username to the %USERNAME& environment variable. That fixed the issue. Everything you can do in the administrator is now able to be done in the regular user command line as well.
0
1
0
0
2012-07-02T15:23:00.000
3
0.066568
false
11,296,583
0
0
0
3
I'm on Windows 7 and if I type "python" in the command prompt as my regular user, I get the old, "'python' is not recognized as an internal or external command, operable program or batch file." but if I open the prompt as the administrator, python initiates like it should. The very first thing I did was edit the PATH variables through Control Panel, which seemed to add the environment variable, but there's a disconnect between doing this and cmd recognizing that I've done it. I have changed the permissions on the Python27 folder to allow full access to all users, I've tried adding a pythonexe variable and add that to the PATH, as another StackOverflow question suggested. When I type PATH = C:\Python27 into cmd as a regular user, that also wont work. and if I type in set PATH, "C:\Python27;" is in the returned line. I'm fairly certain it's a permission problem, which is the only reason I've re-posted my own version of this age old question. How do I run Python, given this error and these circumstances?
"python" only runs from command prompt as Admin
37,835,125
0
1
2,992
0
python,cmd
I've experienced a similar issue in the past and found that also checking the order of the values in the environmental/system variables matters as well.
0
1
0
0
2012-07-02T15:23:00.000
3
0
false
11,296,583
0
0
0
3
I'm on Windows 7 and if I type "python" in the command prompt as my regular user, I get the old, "'python' is not recognized as an internal or external command, operable program or batch file." but if I open the prompt as the administrator, python initiates like it should. The very first thing I did was edit the PATH variables through Control Panel, which seemed to add the environment variable, but there's a disconnect between doing this and cmd recognizing that I've done it. I have changed the permissions on the Python27 folder to allow full access to all users, I've tried adding a pythonexe variable and add that to the PATH, as another StackOverflow question suggested. When I type PATH = C:\Python27 into cmd as a regular user, that also wont work. and if I type in set PATH, "C:\Python27;" is in the returned line. I'm fairly certain it's a permission problem, which is the only reason I've re-posted my own version of this age old question. How do I run Python, given this error and these circumstances?
Need to get IP address to add to GAE blacklist
11,304,280
1
0
283
0
python,google-app-engine,ip,blacklist,denial-of-service
You could see the IP on the Logs page in the admin panel. Click the 'plus' icon next to a log item in order to expand it and view request data.
0
1
0
0
2012-07-03T03:56:00.000
1
0.197375
false
11,304,235
0
0
1
1
I'm getting a lot of requests to my appengine app from a malicious user and I suspect it might be an attempt at a DOS attack. I need to add thier IP address to blacklists on GAE. However when I look at self.request.remote_addr all I get is my own IP address. How can I get the remote IP of the client that is actually sending me these requests?
Update App Engine Tasks?
11,308,295
1
2
294
0
python,google-app-engine,task-queue
With pull queues, you can use modify_task_lease to set the ETA relative to the current time (even if you do not currently have the task leased). You can't change the ETA of a pull queue task. Each task's name remains unavailable for seven days.
0
1
0
0
2012-07-03T04:53:00.000
2
0.099668
false
11,304,679
0
0
1
2
Is it possible to update an AppEngine task in the task queue? Specifically, changing the eta property of the task to make it run at a different time? In my scenario, each item in my datastore has an associated task attached to it. If the element is updated, the task needs to updated with a new eta. I currently set the name of the task explicitly as the id of the item using name=item.key().id() so that I can uniquely refer to the task. When the task is called and deleted, the name doesn't get freed immediately (I think). This causes issues because I need to re-add the task as soon as it gets executed.
Update App Engine Tasks?
11,313,223
1
2
294
0
python,google-app-engine,task-queue
So I resolved this in the following way: I created an entry in my Model for a task_name. When I create the element and add a new task, I allow app engine to generate an automated, unique name for the task then retrieve the name of that task and save it with the model. This allows me to have that reference to the task. When I need to modify the task, I simply delete the existing one, create a new one with the new eta and then save the new task's name to the model. This is working so far, but there might be issues in the future regarding tasks not being consistent when the Task.add() function returns.
0
1
0
0
2012-07-03T04:53:00.000
2
1.2
true
11,304,679
0
0
1
2
Is it possible to update an AppEngine task in the task queue? Specifically, changing the eta property of the task to make it run at a different time? In my scenario, each item in my datastore has an associated task attached to it. If the element is updated, the task needs to updated with a new eta. I currently set the name of the task explicitly as the id of the item using name=item.key().id() so that I can uniquely refer to the task. When the task is called and deleted, the name doesn't get freed immediately (I think). This causes issues because I need to re-add the task as soon as it gets executed.
compiling+distributing Linux code on Windows
11,347,955
0
2
534
0
c++,python,windows,linux,porting
I think your choice here depends on your goals for compiling under Windows. Are you preparing to involve other developers that can choose their development platform? Do you want to use a different compiler for additional warnings generation? Are you looking to deploy the application on the windows platform? Asking these kinds of questions should help you make a more informed decision. Here are some suggestions... It doesn't hurt to try MSVC. The 2010 express edition is the last free edition to support standard C++ development. Future express editions are for "Metro" apps only. I would weigh that against your goals for Windows development and choose accordingly. For a cross platform build, see if you can implement a standardized build system such as CMake or SCons. I wouldn't ship with dependencies, regardless of the final decision. It is standard practice for Open Source to require developers to download dependencies individually. Just be sure to include version information for anything where the current stable release is not backwards compatible with your application. (Or even better, FIX those problems so you get the benefit of the latest fixes in 3rd party code.) Python, at the very least, should be the responsibility of the developer. It is meant to be installed, and pywin32 extensions will register COM items in the system registry on a Windows installation. As far as recruiting Open Source developers, you may find that requiring MinGW to be installed on a developer's machine will discourage some of the dedicated MSVC users from working on the project.
1
1
0
0
2012-07-03T15:29:00.000
1
1.2
true
11,314,253
1
0
0
1
I have a larger code running in Linux, written in c++ (c++11) and python and using numerous libraries (VTK, boost, pyqt, OpenGL) and compiles to python extension modules (and plugins of those modules) and pure python modules (the main program is a python script). The code is cross-platform (with a few exceptions, like dlopen, gettimeofday which can be replaced by windows equivalents via #ifdef's) and compiler-agnostic (it compiles with -ansi, and a few compiler-specific things like __attribute__ can also be, hopefully, replaced, if needed). I am cosindering attempting compilation on Windows, but I am totally lost on how should I proceed (I am fairly experienced with development in Linux, but I have not used Windows since late 90s). Should I go for mingw or MSVC compiler? Would I be better of to cross-compile? Do I need to install dependencies "by hand" by downloading installers from the web; do I need to compile those as well? Are there standard paths for include files, or are all of them to be detected? If I ever manage to compile it, how can make some sort of package (it is a bundle of pure-python modules and shared libs)? I assume I am not the first one who is trying to see how it works under Windows (I reckon I am spoiled by package managers and all dev-friendly things in Linux), perhaps there is a helpful reference somewhere.
Spawning a non-child process in python
11,316,397
4
2
1,204
0
python,process,subprocess,popen
Terminating the parent process does not terminate child processes in Unix-like operating systems, so you don't need to do anything special. Just start your subprocesses with subprocess.Popen and terminate the main process. The orphaned processes will automatically be adopted by init.
0
1
0
0
2012-07-03T17:47:00.000
1
0.664037
false
11,316,369
1
0
0
1
I need to create spawn off a process in python that allows the calling process to exit while the child is still running. What is an effective way to do this? Note: I'm running on a UNIX environment.
key/value store with good performance for multiple tenants
11,319,983
0
1
239
1
javascript,python,google-app-engine,nosql,multi-tenant
The overhead of making calls from appengine to these external machines is going to be worse than the performance you're seeing now (I would expect). why not just move everything to a non-appengine machine? I can't speak for couch, but mongo or redis are definitely capable of handling serious load as long as they are set up correctly and with enough horsepower for your needs.
0
1
0
0
2012-07-03T22:08:00.000
2
0
false
11,319,890
0
0
1
2
im running a multi tenant GAE app where each tenant could have from a few 1000 to 100k documents. at this moment im trying to make a MVC javascript client app (the admin part of my app with spine.js) and i need CRUD endpoints and the ability to get a big amount of serialized objects at once. for this specific job appengine is way to slow. i tried to store serialized objects in the blobstore but between reading/writing and updating stuff to the blobstore it takes too much time and the app gets really slow. i thought of using a nosql db on an external machine to do these operations over appengine. a few options would be mongodb, couchdb or redis. but i am not sure about how good they perform with that much data and concurrent requests/inserts from different tenants. lets say i have 20 tenants and each tenant has 50k docs. are these dbs capable to handle this load? is this even the right way to go?
key/value store with good performance for multiple tenants
11,323,377
2
1
239
1
javascript,python,google-app-engine,nosql,multi-tenant
Why not use the much faster regular appengine datastore instead of blobstore? Simply store your documents in regular entities as Blob property. Just make sure the entity size doesn't exceed 1 MB in which case you have to split up your data into more then one entity. I run an application whith millions of large Blobs that way. To further speed up things use memcache or even in-memory cache. Consider fetching your entites with eventual consistency which is MUCH faster. Run as many database ops in parallel as possible using either bulk operations or the async API.
0
1
0
0
2012-07-03T22:08:00.000
2
1.2
true
11,319,890
0
0
1
2
im running a multi tenant GAE app where each tenant could have from a few 1000 to 100k documents. at this moment im trying to make a MVC javascript client app (the admin part of my app with spine.js) and i need CRUD endpoints and the ability to get a big amount of serialized objects at once. for this specific job appengine is way to slow. i tried to store serialized objects in the blobstore but between reading/writing and updating stuff to the blobstore it takes too much time and the app gets really slow. i thought of using a nosql db on an external machine to do these operations over appengine. a few options would be mongodb, couchdb or redis. but i am not sure about how good they perform with that much data and concurrent requests/inserts from different tenants. lets say i have 20 tenants and each tenant has 50k docs. are these dbs capable to handle this load? is this even the right way to go?
Does python have a tool similar to Java's JPS
11,333,155
1
2
1,045
0
python,process
No. Each Python script has its own independent interpreter, so there is no convenient way to list all Python processes.
0
1
0
0
2012-07-04T17:00:00.000
3
0.066568
false
11,333,061
1
0
1
2
Does Python have a tool to list python processes similar to Java's jps (http://docs.oracle.com/javase/6/docs/technotes/tools/share/jps.html)? Edit: Getting the pid's of python processes is relatively easy (ps -A | grep python). What I am really looking for is a way to query a currently-running python process and find out the python file it was originally executed on. From the JPS docs, "jps will list each Java application's lvmid followed by the short form of the application's class name or jar file name." Basically, is there an easy way to query a bunch of python processes and find out useful information like JPS does for JVMs?
Does python have a tool similar to Java's JPS
12,424,762
1
2
1,045
0
python,process
The best way I've found to get the information I need is using ps -x, which gives the original command line arguments of all running processes.
0
1
0
0
2012-07-04T17:00:00.000
3
1.2
true
11,333,061
1
0
1
2
Does Python have a tool to list python processes similar to Java's jps (http://docs.oracle.com/javase/6/docs/technotes/tools/share/jps.html)? Edit: Getting the pid's of python processes is relatively easy (ps -A | grep python). What I am really looking for is a way to query a currently-running python process and find out the python file it was originally executed on. From the JPS docs, "jps will list each Java application's lvmid followed by the short form of the application's class name or jar file name." Basically, is there an easy way to query a bunch of python processes and find out useful information like JPS does for JVMs?
Python/Django development, windows or linux?
11,339,389
1
19
25,407
0
python,windows,django,linux
I normally use OSX on my desktop, but I use Linux for Python because that's how it will get deployed. Specifically, I use Ubuntu Desktop in a virtual machine to develop Python applications and I use Ubuntu on the server to deploy them. This means that my understanding of library and module requirements/dependencies are 100% transferrable to the server when I'm ready to deploy the application. If I used OSX (or Windows) to develop Python apps I would have to deal with two different methods of handling requirements and dependencies --- it's just too much work. My suggestion: use VMWare Player (it's free) and find a Ubuntu VM to start learning. It's not too complicated and is actually quite fun.
0
1
0
0
2012-07-05T05:43:00.000
5
0.039979
false
11,338,382
0
0
1
2
I have been working on Python quite a lot recently and started reading the doc for Django, however I can't deny the fact that most of the video tutorials I find usually shows Linux as the chosen OS. I've ignored this mostly, but I started to come upon some problems with people using commands such as "touch" for which I have no idea about what the equivalent is in the Windows 7 command prompt. I've heard about New-Item in Power Shell, however it's messy and I am fearing that this "equivalent hunt" might come again and again... So I started to wonder why were most of the people using Linux with Python, would be a good move (knowing that my Linux knowledge is completely null) to learn to use Linux for development purpose? Would it allow me to be more efficient at developing with Python in general? Would it be possible to list the benefits of doing so?
Python/Django development, windows or linux?
11,338,865
27
19
25,407
0
python,windows,django,linux
I used Windows for quite some time for Django development, but finally figured out that Linux is simply the better way to go. Here are some reasons why: some Python packages can not be installed at all or correctly in Windows OR it will create a lot of hassle for you to do so if you need to deploy your Django app it makes more sense to use a Unix-flavored system, simply because its 99% likely that you deployment environment is the same. Doing a dry run on your local machine with the same configuration will save you a lot of time later on + here you are "allowed" to make mistakes. If your apps gets complex its way easier in Linux to get the required dependencies, be it extensions, libraries, etc.. In Windows you end up looking for the right site to download everything and go through some hassle of installation and configuration. It took me lots of time to just search for some specific things sometimes. In Linux its often just an "apt-get" (or similiar) and you are done. Did I mention that everything is faster to get and install in Linux? Of course if your app is simple and you don't need to care about the deployment then Windows is fine.
0
1
0
0
2012-07-05T05:43:00.000
5
1.2
true
11,338,382
0
0
1
2
I have been working on Python quite a lot recently and started reading the doc for Django, however I can't deny the fact that most of the video tutorials I find usually shows Linux as the chosen OS. I've ignored this mostly, but I started to come upon some problems with people using commands such as "touch" for which I have no idea about what the equivalent is in the Windows 7 command prompt. I've heard about New-Item in Power Shell, however it's messy and I am fearing that this "equivalent hunt" might come again and again... So I started to wonder why were most of the people using Linux with Python, would be a good move (knowing that my Linux knowledge is completely null) to learn to use Linux for development purpose? Would it allow me to be more efficient at developing with Python in general? Would it be possible to list the benefits of doing so?
Will it be practical to implement deb preinst, postint, etc. scripts in Python, not in sh
11,350,615
8
9
912
0
python,debian,packaging,deb
The only reason this isn't commonly done, afaik, is that it's not convention, and Python isn't usually more useful or straightforward than plain shell script for the sorts of things that maintainer scripts do. When it is more useful, you can often break out the Python-needing functionality into a separate Python script which is called by the maintainer scripts. It can help to follow convention in this sort of situation, since there are a lot of helpful tools and scripts (e.g., Lintian, Debhelper) which generally assume that maintainer scripts use bash. If they don't, it's ok, but those tools may not be as useful as they would be otherwise. The only other issue I think you need to be aware of is that if your preinst or postrm scripts need Python, then Python needs to be a pre-dependency (Pre-Depends) of your package instead of just a Depends. That said, I've found it useful to use Python in a maintainer script before.
0
1
0
1
2012-07-05T15:28:00.000
1
1.2
true
11,347,613
0
0
0
1
I'm interested in what pitfalls can be (except Python is not installed in target system) when using Python for deb package flow control scripts (preinst, postinst, etc.). Will it be practical to implement those scripts in Python, not in sh? As I understand it's at least possible.
Scraper Google App Engine for Steam
11,350,089
1
0
614
0
jquery,python,html,google-app-engine,steam-web-api
Since you have the steam id from the service you can then make another request to their steam community page via the id. From there you can use beautiful soup to return a dom to grab the required information for your project. Now onto your question. You can have all this happen within a request in a handler, if you are using a web framework such as Tornado, and the handler can return json in the page and you can render this json using your javascript code. Look into a web framework for python such as Tornado or Django to help you with return and displaying the data.
0
1
0
0
2012-07-05T17:46:00.000
2
0.099668
false
11,349,709
0
0
1
1
So basically, at the moment, we are trying to write a basic HTML 5 page that, when you press a button, returns whether the user, on Steam, is in-game, offline, or online. We have looked at the Steam API, and to find this information, it requires the person's 64 bit ID (steamID64) and we, on the website, are only given the username. In order to find their 64 bit id, we have tried to scrape off of a website (steamidconverter.com) to get the user's 64 bit id from their username. We tried doing this through the javascript, but of course we ran into the cross domain block, not allowing us to access that data from our google App Engine website. I have experience in Python, so I attempted to figure out how to get the HTML from that website (in the form of steamidconverter.com/(personsusername)) with Python. That was a success in scraping, thanks to another post on Stack Overflow. BUT, I have no idea how to get that data back to the javascript and get it to do the rest of the work. I am stumped and really need help. This is all on google App Engine. All it is at the moment, is a button that runs a simple javascript that attempts to use JQuery to get the contents of the page back, but fails. I don't know how to integrate the two! Please Help!
What's the difference between timer and rbtimer in uWSGI?
11,353,126
11
5
826
0
python,timer,uwsgi
@timer uses kernel-level facilities, so they are limited in the maximum number of timers you can create. @rbtimer is completely userspace so you can create an unlimited number of timers at the cost of less precision
0
1
0
1
2012-07-05T19:06:00.000
1
1.2
true
11,350,907
0
0
1
1
I'm looking to add simple repeating tasks to my current application and I'm looking at the uwsgi signals api and there are two decorators @timer and @rbtimer. I've tried looking through the doc and even the python source at least but it appears it's probably more low level than that somewhere in the c implementation. I'm familiar with the concept of a red-black tree but I'm not sure how that would relate to timers. If someone could clear things up or point me to the doc I might have missed I'd appreciate it.
How do I make a Python script log out of the shell when it exits?
11,356,753
5
2
1,998
0
python,bash,shell
Set your python script as the login shell of the user(in /etc/passwd/). This way she will be automatically logged out after the script exits.
0
1
0
0
2012-07-06T06:04:00.000
4
0.244919
false
11,356,681
0
0
0
1
I'm writing a shell script in Python for bash. The script automatically runs when the user logs into the account, and I want it to log the user out when it exits. I tried using os.system('exit'), but it doesn't work. How would I achieve this?
What's the difference between /usr/lib/python and /usr/lib64/python?
11,370,887
4
10
10,916
0
python
The 64-bit version of the libraries? What version of Python are you running? If you are running the 32-bit version, then you probably won't need those files.
0
1
0
1
2012-07-06T23:24:00.000
2
1.2
true
11,370,877
1
0
0
1
I was using ubuntu. I found that many Python libraries installed went in both /usr/lib/python and /usr/lib64/python. When I print a module object, the module path showed that the module lived in /usr/lib/python. Why do we need the /usr/lib64/python directory then? What's the difference between these two directories? BTW Some package management script and egg-info that lived in both directories are actually links to packages in /usr/share. Most Python modules are just links, but the so files are not.
How to change the working directory for a shell script (newbie here)
11,387,734
1
0
2,233
0
python,linux,shell
The process that starts your python script (probably forkink) has a pwd (its working directory). The idea is to change the pwd of the process before to fork and execute python. You need to look over the manual of the process that executes the shell command, and see how to set the pwd.(in shell you use cd or pushd)
0
1
0
0
2012-07-09T00:00:00.000
3
0.066568
false
11,387,702
0
0
0
1
I have a python script that looks files up in a relative directory. For example: the python script is in /home/username/projectname/. I have a file that is being called within the python script that is in /home/username/projectname/subfolder. If I run the script from the shell as python scriptname.py it runs perfectly fine. However, i'm trying to run the script as a startup service. I'm setting it up in webmin, and I believe its using a terminal command to call it. In the startup command, I'm doing something like this to call the script: execute python home/username/projectname/scriptname.py. The script is starting up fine, but I get an error because it cant access the files in the relative directory. I am guessing that there is a better way to call the python program from within the startup command so that its aware of the relative path.
Receive HTTP request in one Python process, reply from another
11,394,262
0
1
152
0
python,events,io,response,multiprocessing
You can't. Only one process can have access to one port at one time and you cannot respond directly without accessing the port. But you don't need that. What you need is proxy! You can add a thread to your app which will listen on a different port. Then you fire your image process and when that process finishes its work you can send the result to the port. Then you're thread will read it and send the response.
0
1
0
0
2012-07-09T11:01:00.000
1
0
false
11,393,770
1
0
0
1
Can I "move" response object somehow from one process to another? The first process is a non-blocking server which does some other IO. It needs to be done in a non-blocking environment like Tornado or Twisted or something like this. Another process (actually, a pool of "worker" processes) is needed to process images with PIL. I can't do it in threads because of GIL. However, either the worker needs to get a file-handle of response object to write the result to, or it should return the result back to the first process, and since the result can be pretty huge (~1 mb), it does not seem like a good idea. (It's probably going to be a separate pool of processes, not a fork for every request - the latter one seems like a bad strategy) So, can I somehow allow the worker process to write to the response directly?
Python startup script
11,404,208
7
11
28,023
0
python,startup
Python has a special script that is run on startup. On my platform it is located at /usr/lib/python2.5/site-packages/sitecustomize.py IIRC. So, you could either put init.py in that directory alongside a sitecustomize.py script that imports it, or just paste the content of init.py in the sitecustomize.py.
0
1
0
0
2012-07-09T22:32:00.000
2
1
false
11,404,165
1
0
0
1
I would like to execute a script work.py in Python, after executing some initialization script init.py. If I were looking for an interactive session, executing python -i init.py or setting PYTHONSTARTUP=/path/to/init.py would do the trick, but I am looking to execute another script. Since this is a generic case which occurs often (init.py sets environment and so is the same all of the time), I would highly prefer not referencing init.py from work.py. How could this be done? Would anything change if I needed this from a script instead of from the prompt? Thank you very much.
How do I install PyCrypto on Windows?
56,252,476
5
152
355,117
0
python,windows,python-2.7,pycrypto
If you are on Windows and struggling with installing Pycrypcto just use the: pip install pycryptodome. It works like a miracle and it will make your life much easier than trying to do a lot of configurations and tweaks.
0
1
0
0
2012-07-10T01:44:00.000
19
0.052583
false
11,405,549
1
0
0
4
I've read every other google source and SO thread, with nothing working. Python 2.7.3 32bit installed on Windows 7 64bit. Download, extracting, and then trying to install PyCrypto results in "Unable to find vcvarsall.bat". So I install MinGW and tack that on the install line as the compiler of choice. But then I get the error "RuntimeError: chmod error". How in the world do I get around this? I've tried using pip, which gives the same result. I found a prebuilt PyCrypto 2.3 binary and installed that, but it's nowhere to be found on the system (not working). Any ideas?
How do I install PyCrypto on Windows?
45,761,612
3
152
355,117
0
python,windows,python-2.7,pycrypto
My answer might not be related to problem mention here, but I had same problem with Python 3.4 where Crypto.Cipher wasn't a valid import. So I tried installing PyCrypto and went into problems. After some research I found with 3.4 you should use pycryptodome. I install pycryptodome using pycharm and I was good. from Crypto.Cipher import AES
0
1
0
0
2012-07-10T01:44:00.000
19
0.031568
false
11,405,549
1
0
0
4
I've read every other google source and SO thread, with nothing working. Python 2.7.3 32bit installed on Windows 7 64bit. Download, extracting, and then trying to install PyCrypto results in "Unable to find vcvarsall.bat". So I install MinGW and tack that on the install line as the compiler of choice. But then I get the error "RuntimeError: chmod error". How in the world do I get around this? I've tried using pip, which gives the same result. I found a prebuilt PyCrypto 2.3 binary and installed that, but it's nowhere to be found on the system (not working). Any ideas?
How do I install PyCrypto on Windows?
11,405,593
2
152
355,117
0
python,windows,python-2.7,pycrypto
This probably isn't the optimal solution but you might download and install the free Visual C++ Express package from MS. This will give you the C++ compiler you need to compile the PyCrypto code.
0
1
0
0
2012-07-10T01:44:00.000
19
0.02105
false
11,405,549
1
0
0
4
I've read every other google source and SO thread, with nothing working. Python 2.7.3 32bit installed on Windows 7 64bit. Download, extracting, and then trying to install PyCrypto results in "Unable to find vcvarsall.bat". So I install MinGW and tack that on the install line as the compiler of choice. But then I get the error "RuntimeError: chmod error". How in the world do I get around this? I've tried using pip, which gives the same result. I found a prebuilt PyCrypto 2.3 binary and installed that, but it's nowhere to be found on the system (not working). Any ideas?
How do I install PyCrypto on Windows?
51,176,072
0
152
355,117
0
python,windows,python-2.7,pycrypto
I had Pycharm for python. Go to pycharm -> file -> setting -> project interpreter Click on + Search for "pycrypto" and install the package Note: If you don't have "Microsoft Visual C++ Compiler for Python 2.7" installed then it will prompt for installation, once installation finished try the above steps it should work fine.
0
1
0
0
2012-07-10T01:44:00.000
19
0
false
11,405,549
1
0
0
4
I've read every other google source and SO thread, with nothing working. Python 2.7.3 32bit installed on Windows 7 64bit. Download, extracting, and then trying to install PyCrypto results in "Unable to find vcvarsall.bat". So I install MinGW and tack that on the install line as the compiler of choice. But then I get the error "RuntimeError: chmod error". How in the world do I get around this? I've tried using pip, which gives the same result. I found a prebuilt PyCrypto 2.3 binary and installed that, but it's nowhere to be found on the system (not working). Any ideas?
Quick way to know if a file is open on Linux?
11,411,496
0
2
1,556
0
python,linux
You can check the modification time of the file and see if it has not been modified for a period of time. Since a file can be opened in update mode and be modified any time, you cannot be 100% sure that it will never be modified.
0
1
0
0
2012-07-10T10:31:00.000
11
0
false
11,411,428
0
0
0
5
Is there a quick way (i.e. that minimizes time-to-answer) to find out if a file is open on Linux? Let's say I have a process that writes a ton a files in a directory and another process which reads those files once they are finished writing, can the latter process know if a file is still being written to by the former process? A Python based solution would be ideal, if possible. Note: I understand I could be using a FIFO / Queue based solution but I am looking for something else.
Quick way to know if a file is open on Linux?
11,411,514
1
2
1,556
0
python,linux
If you can change the 'first' process logic, the easy solution would be to write data to a temp file and rename the file once all the data is written.
0
1
0
0
2012-07-10T10:31:00.000
11
0.01818
false
11,411,428
0
0
0
5
Is there a quick way (i.e. that minimizes time-to-answer) to find out if a file is open on Linux? Let's say I have a process that writes a ton a files in a directory and another process which reads those files once they are finished writing, can the latter process know if a file is still being written to by the former process? A Python based solution would be ideal, if possible. Note: I understand I could be using a FIFO / Queue based solution but I am looking for something else.
Quick way to know if a file is open on Linux?
11,411,550
2
2
1,556
0
python,linux
lsof | grep filename immediately comes to mind.
0
1
0
0
2012-07-10T10:31:00.000
11
0.036348
false
11,411,428
0
0
0
5
Is there a quick way (i.e. that minimizes time-to-answer) to find out if a file is open on Linux? Let's say I have a process that writes a ton a files in a directory and another process which reads those files once they are finished writing, can the latter process know if a file is still being written to by the former process? A Python based solution would be ideal, if possible. Note: I understand I could be using a FIFO / Queue based solution but I am looking for something else.
Quick way to know if a file is open on Linux?
11,411,884
0
2
1,556
0
python,linux
You can use fcntl module, afaik, it's has fcntl function that identical to C function, so something like fcntl(fd, F_GETFL) could be useful, but I'm not sure. Can you check is target file is blocked for writing by opening it in write mode?
0
1
0
0
2012-07-10T10:31:00.000
11
0
false
11,411,428
0
0
0
5
Is there a quick way (i.e. that minimizes time-to-answer) to find out if a file is open on Linux? Let's say I have a process that writes a ton a files in a directory and another process which reads those files once they are finished writing, can the latter process know if a file is still being written to by the former process? A Python based solution would be ideal, if possible. Note: I understand I could be using a FIFO / Queue based solution but I am looking for something else.
Quick way to know if a file is open on Linux?
11,411,493
10
2
1,556
0
python,linux
You can of course use INOTIFY feature of Linux, but it is safer to avoid the situation: let the writing process create the files (say data.tmp) which the reading process will definitely ignore. When the writer finishes, it should just rename the file for the reader (into say .dat). The rename operation guarantees that there may be no misunderstandings.
0
1
0
0
2012-07-10T10:31:00.000
11
1.2
true
11,411,428
0
0
0
5
Is there a quick way (i.e. that minimizes time-to-answer) to find out if a file is open on Linux? Let's say I have a process that writes a ton a files in a directory and another process which reads those files once they are finished writing, can the latter process know if a file is still being written to by the former process? A Python based solution would be ideal, if possible. Note: I understand I could be using a FIFO / Queue based solution but I am looking for something else.
Cross-compiling in Python in Windows TO Linux/OSX
11,437,392
2
3
2,026
0
python,windows,python-2.7,cross-compiling
Get Virtualbox, install Ubuntu in it, and build it "natively" in for Linux. These things work really well, and cross compilation is just asking for trouble. You're going to eventually need Linux to answer the support questions you'll get from these customers anyway! :(
0
1
0
0
2012-07-11T16:35:00.000
2
0.197375
false
11,437,271
1
0
0
1
I have a program I've written in Python 2.7 on Windows, and I've been using py2exe with total success to make it into an exe (and associated files). However, a reasonable number of people who I want to use it are on Linux/OSX, and while some have been able to make the Windows version work with Wine, others have not been so successful. I've looked thoroughly into py2installer, py2app, freeze and others, but if I understand correctly (I am new to Python and very new to compiling) you need to run them on the system you want to compile them for, i.e. you can only compile for Linux on Linux and OSX on OSX. I don't want to distribute just the raw files because I want the source code to be obfuscated as it is inside a .exe, amd obviously not everyone has Python. So, my question is: is there any way to compile for OSX or Linux, in Python, while on a Windows machine? And if not, what do you think the best alternative solution might be?
Geany unable to execute Python
45,036,410
0
6
15,525
0
python,windows-7,geany
I faced this issue. Added python to PATH, working fine on cmd. But Geany wasn't able to execute. Turns out, while saving the file, I had not entered .py as extension. Once I did it, worked fine.
0
1
0
0
2012-07-11T19:01:00.000
4
0
false
11,439,607
1
0
0
2
I'm not a great coder, in fact I'm just trying to learn, but I can't get Geany to regonise Python in my system (Windows 7) when I try to execute the program. When I click Execute, it opens a command prompt saying: 'python' is not recognized as an internal or external command, operable program or batch file How can I fix this?
Geany unable to execute Python
13,714,776
2
6
15,525
0
python,windows-7,geany
I had the same problem and found that setting the path as described in the other prior posts was necessary but not sufficient. In my case, I had saved my script to the "geany" directory. It turns out that there was a permissions problem with the geany editor trying to create a temporary file in the geany folder. As soon as I saved my script to another folder the permissions error went away.
0
1
0
0
2012-07-11T19:01:00.000
4
0.099668
false
11,439,607
1
0
0
2
I'm not a great coder, in fact I'm just trying to learn, but I can't get Geany to regonise Python in my system (Windows 7) when I try to execute the program. When I click Execute, it opens a command prompt saying: 'python' is not recognized as an internal or external command, operable program or batch file How can I fix this?
How I can make apt-get install to my virtualenv?
53,515,591
3
30
30,665
0
python,virtualenv,apt-get
An alternative solution is to install globally, then followed by allowing the virtualenv to be able to see it. As an example, let's say we want to install matplotlib for Python 3: sudo apt update # Update first sudo apt install python3-matplotlib # Install globally sudo pip3 install -U virtualenv # Install virtualenv for Python 3 using pip3 virtualenv --system-site-packages -p python3 ./venv #the system-site-packages option allows venv to see all global packages including matplotlib source ./venv/bin/activate #activate the venv to use matplotlib within the virtualenv deactivate # don't exit until you're done using the virtualenv
0
1
0
0
2012-07-11T21:11:00.000
5
0.119427
false
11,441,546
1
0
0
1
It it's possible, of course. For example - I can download python-dbus like this: $ sudo apt-get download python-dbus But what I should to do next, with this .deb package in my current virtualenv?
python handling subprocess
20,869,726
0
2
144
0
python,for-loop,subprocess
A common way to detect things that have stopped working is to have them emit a signal at roughly regular intervals and have another process monitor the signal. If the monitor sees that no signal has arrived after, say, twice the interval it can take action such as killing and restarting the process. This general idea can be used not only for software but also for hardware. I have used it to restart embedded controllers by simply charging a capacitor from an a.c. coupled signal from an output bit. A simple detector monitors the capacitor and if the voltage ever falls below a threshold it just pulls the reset line low and at the same time holds the capacitor charged for long enough for the controller to restart. The principle for software is similar; one way is for the process to simply touch a file at intervals. The monitor checks the file modification time at intervals and if it is too old kills and restarts the process. In OP's case the subprocess could write a status code to a file to say how far it has got in its work.
0
1
0
0
2012-07-11T23:18:00.000
2
0
false
11,442,944
0
0
0
2
I am running an os.system(cmd) in a for-loop. Since sometimes it hangs, I am trying to use process=subprocess.pOpen(cmd) in a for-loop. But I want to know the following: If I do sleep(60) and then check if the process is still running by using process.poll(), how do I differentiate between process actually running even after 1 minute and process that hung? If I kill the process which hung, will the for-loop still continue or will it exit? Thanks!
python handling subprocess
11,443,356
4
2
144
0
python,for-loop,subprocess
I don't know of any general way to tell whether a process is hung or working. If a process hangs due to a locking issue, then it might consume 0% CPU and you might be able to guess that it is hung and not working; but if it hangs with an infinite loop, the process might make the CPU 100% busy but not accomplish any useful work. And you might have a process communicating on the network, talking to a really slow host with long timeouts; that would not be hung but would consume 0% CPU while waiting. I think that, in general, the only hope you have is to set up some sort of "watchdog" system, where your sub-process uses inter-process communication to periodically send a signal that means "I'm still alive". If you can't modify the program you are running as a sub-process, then at least try to figure out why it hangs, and see if you can then figure out a way to guess that it has hung. Maybe it normally has a balanced mix of CPU and I/O, but when it hangs it goes in a tight infinite loop and the CPU usage goes to 100%; that would be your clue that it is time to kill it and restart. Or, maybe it writes to a log file every 30 seconds, and you can monitor the size of the file and restart it if the file doesn't grow. Or, maybe you can put the program in a "verbose" mode where it prints messages as it works (either to stdout or stderr) and you can watch those. Or, if the program works as a daemon, maybe you can actively query it and see if it is alive; for example, if it is a database, send a simple query and see if it succeeds. So I can't give you a general answer, but I have some hope that you should be able to figure out a way to detect when your specific program hangs. Finally, the best possible solution would be to figure out why it hangs, and fix the problem so it doesn't happen anymore. This may not be possible, but at least keep it in mind. You don't need to detect the program hanging if the program never hangs anymore! P.S. I suggest you do a Google search for "how to monitor a process" and see if you get any useful ideas from that.
0
1
0
0
2012-07-11T23:18:00.000
2
1.2
true
11,442,944
0
0
0
2
I am running an os.system(cmd) in a for-loop. Since sometimes it hangs, I am trying to use process=subprocess.pOpen(cmd) in a for-loop. But I want to know the following: If I do sleep(60) and then check if the process is still running by using process.poll(), how do I differentiate between process actually running even after 1 minute and process that hung? If I kill the process which hung, will the for-loop still continue or will it exit? Thanks!
How can I get pyflakes to run on Windows?
16,672,834
6
4
5,388
0
python,windows,pyflakes
Maybe this question is a bit old, because running "pip install pyflakes" worked flawlessly on Windows to me...
0
1
0
0
2012-07-12T02:26:00.000
3
1
false
11,444,245
1
0
0
1
Having trouble getting pyflakes to run on windows. On Windows there is no apt install , so... what to do?
Google App Engine - Choosing the right direction
11,460,359
4
0
2,564
0
python,django,google-app-engine,webapp2
The short answer is you can probably go either way, there will be some pros/some cons, but I don't think either is pure win. Here's some pros for using Django-nonrel as a newb: The django docs are generally pretty good. So it helps you get up to speed on some best practices CSRF protection Form validation sessions auth i8n tools You spend less time putting various basic pieces together, django has quite a lot for you. You can potentially save time on stuff like FB/Twitter auth, since there's third party django packages for that. Tastypie is a good rest api package, though you probably don't need it with the new Endpoints The django test framework is great, though the Django 1.4 live test framework (which is even greater) doesn't work for App Engine. I just discovered that yesterday and am trying (so far fruitlessly) to hack it to work. django has a simple tool for dumping the DB to json.  This is pretty useful for testing purposes, for loading/saving fixtures.  You'll have to figure out a way to do this yourself otherwise. cons: Django-nonrel isn't the latest and greatest. For one, you won't have ndb benefits. While django docs are great, django-nonrel docs are not, so you'll have to figure out the setup part. I've been meaning to do a writeup, but haven't had time. Time spent learning django could just as well be spent learning something else, but I think django probably takes less time to learn than a few different pieces. Some people have said django is overweight and takes much longer to load. django-nonrel includes all the django-contrib addins. I've removed many of those and have had no load time problems. (fingers crossed) There's prob more people using webapp2+jinja, I don't see too many separate individuals chiming in on django-nonrel specific issues, though the ones that do have been very helpful. On the other hand, if you run into a generic django problem, there's a lot of django users. One thing I can say though, is if you've written for django, it's hard to move away from it piecemeal. You'll have to have replaced all the pieces that you're using before you can get rid of it, otherwise, you'll still have to include most of the package. An alternative to using django that I know of is gae-boilerplate. It tries to do the same thing but with various different pieces. It still needs a good testing framework though imo.
0
1
0
0
2012-07-12T19:13:00.000
3
0.26052
false
11,458,969
0
0
1
1
I started web development 2 weeks ago using GAE,WebApp2,Jinja2 and WTForms. I read though several articles , discussions , watched lessons about web development with gae (udacity) and started a small project. Now I am very inexperienced in web-development and I don't know which path i should choose. . . The last few days I poked around with GAE and webapp2. It was very easy to use. But I have to say that i only used webapp2 has a request handler. (post / get) For templates I took Jinja2 which was self explanatory too. . . Now Steve from Reddit said that it's always better to use a lightweight framework instead of a very big framework because you have more control and you can scale a lot easier. But I still want to investigate Django-nonrel. I know that Django is limited in GAE. But to be honest I don't even know what Django does for me, (compared to WebApp2 with Jinja2) Now to my questions: Would you recommend a beginner to have a look into Django ? And if I am more experienced => replace some Django code. Stick to WebApp2 + "some template engine" ? . . PS: I don't ask which framework is the best, I just want some points for consideration.
Google App Engine + Google Cloud Storage + Sqlite3 + Django/Python
11,498,320
0
1
2,078
1
python,django,sqlite,google-app-engine,google-cloud-storage
No. SQLite requires native code libraries that aren't available on App Engine.
0
1
0
0
2012-07-12T23:44:00.000
3
1.2
true
11,462,291
0
0
1
2
since it is not possible to access mysql remotely on GAE, without the google cloud sql, could I put a sqlite3 file on google cloud storage and access it through the GAE with django.db.backends.sqlite3? Thanks.
Google App Engine + Google Cloud Storage + Sqlite3 + Django/Python
11,463,047
0
1
2,078
1
python,django,sqlite,google-app-engine,google-cloud-storage
Google Cloud SQL is meant for this, why don't you want to use it? If you have every frontend instance load the DB file, you'll have a really hard time synchronizing them. It just doesn't make sense. Why would you want to do this?
0
1
0
0
2012-07-12T23:44:00.000
3
0
false
11,462,291
0
0
1
2
since it is not possible to access mysql remotely on GAE, without the google cloud sql, could I put a sqlite3 file on google cloud storage and access it through the GAE with django.db.backends.sqlite3? Thanks.
Set up Python on Windows to not type "python" in cmd
67,924,065
2
27
17,143
0
python,windows,path,cmd
I also had the same issue... I could fix it by re-associating *.py files with the python launcher. Right click on a *.py file and open its properties. Click on the Change button of the "Opens with..." section Select More apps -> Look for another app on this PC. Then browse to your windows folder (by default: "C:\Windows") Select "py.exe"
0
1
0
0
2012-07-13T14:47:00.000
4
0.099668
false
11,472,843
0
0
1
1
How do I have to configure so that I don't have to type python script.py but simply script.py in CMD on Windows? I added my python directory to %PATH% that contains python.exe but still scripts are not run correctly. I tried it with django-admin.py Running django-admin.py startproject mysite gives me Type 'django-admin.py help <subcommand>' for help on a specific subcommand. Using python in front of it processes the command correctly. What's the problem here?
Whats a good command-oriented commandline framework for Python 2 and 3?
11,484,057
5
2
530
0
python,command-line,python-3.x
The argparse module from Python's standard library also supports commands, and it works in both, Python 2.x and 3.x.
0
1
0
0
2012-07-14T13:10:00.000
4
1.2
true
11,484,029
0
0
0
1
I like the cmdln framework for writing programs that work like svn command argument but it only works in Python 2. What's a good Python 3 alternative?
python patch : how to apply
11,489,520
1
1
3,549
0
python,patch,ubuntu-12.04
Unless you are running a custom-compiled version of Python that you pulled from the cvs server (which I'm pretty sure you are not), the best thing to do is to wait until an official build is provided by the Ubuntu packagers. Also, since this bug was found on Apr 19, 2012 and hasn't been bundled into Python 2.7's tarball, it isn't a critical bug. In short, either compile Python from the repository (not recommended), patch the Python library files yourself (they're just Python files, but I wouldn't edit them), or just put up with this cryptic bug that doesn't really affect anyone. I wouldn't worry about it. If it was critical, Python 2.7.4 would've been released with this patch.
0
1
0
0
2012-07-15T04:41:00.000
2
0.099668
false
11,489,481
1
0
0
2
I am using Ubuntu 12.04 LTS; python 2.7.3 is pre-installed. A bug in python 2.7 distribution has been fixed in their repository. changeset 76420:ab9d6c4907e7 2.7 How do I apply this patch on my PC ? Thanks, Vineet
python patch : how to apply
11,489,496
1
1
3,549
0
python,patch,ubuntu-12.04
You can use the mercurial equivalents of following comands: svn log svn diff patch The "hg" equivalents of the first two commands will identify all the files that have changed and the the changes in them. The last command will apply the patches. Use the man command to get detailed usage information on the commands.
0
1
0
0
2012-07-15T04:41:00.000
2
1.2
true
11,489,481
1
0
0
2
I am using Ubuntu 12.04 LTS; python 2.7.3 is pre-installed. A bug in python 2.7 distribution has been fixed in their repository. changeset 76420:ab9d6c4907e7 2.7 How do I apply this patch on my PC ? Thanks, Vineet
Packaging a Python app with PyPI + OS-level dependencies
11,508,441
3
6
220
0
python,packaging,pip,pypi
distribute is a fork of setuptools with better perhaps documentation. You basically have distutils (stdlib) and setuptools as your choices. Since distutils doesn't let you specify dependencies, only setuptools is left. You generally list all dependencies, and document the installation procedure clearly (including in the long_description field pushed to PyPI). Include the OS-level installed packages, most distributions include the egg information when installing these.
0
1
0
0
2012-07-16T16:01:00.000
1
1.2
true
11,508,093
1
0
0
1
I would like to package a Python scientific application for PyPI. My problem is that it relies on PyPI-level deps (e.g. numpy, scipy, etc.) as well as others which must be dealt at the OS-level: wxPython and Python-VTK (e.g. with apt-get on Ubuntu, homebrew on OSX, etc). I'd like to know what would be the ideal strategy for doing this, and in particular, which packaging system would fit best (I'm currently favoring Distribute).
Virtualenv Python 2.4
22,384,632
1
4
1,376
0
python,virtualenv
The support for python2.4 was dropped in virtualenv 1.8 therefore make sure you use virtualenv<=1.7.2.
0
1
0
0
2012-07-16T17:14:00.000
2
0.099668
false
11,509,228
1
0
0
1
When using virtualenv I find that the command: virtualenv -p python2.6 --no-site-packages ~/env/NEW_PROJECT works without any problems, however if I try to do virtualenv -p python2.4 --no-site-packages ~/env/NEW_PROJECT I receive the error "The executable python2.4 (from --python=python2.4) does not exist. Is there a way to setup a virtualenv with python2.4? Thanks
How can I find out if someone is actively using a Linux computer in Python or Java?
11,511,519
0
2
1,087
0
java,python
I second the answer by @Eero Aaltonen -- you should run your stuff under nice. A Linux computer can run at 100% CPU busy, yet feel nice and fast for the user, if the extra tasks are all under nice; the scheduler will only run the nice tasks when the main user's tasks are idle. But if you want to figure out if the machine is being used, I suggest you look into the w command. Try man w at your prompt. The w command prints the load average for the machine, and a list of users and how much time they have been using (a combined time that includes any background tasks they are running, plus a time for their main task).
0
1
0
1
2012-07-16T18:10:00.000
5
0
false
11,510,032
0
0
0
2
I want to write a program that ssh's into remote boxes and runs jobs there if the remote computer is not actively being used. I'll be logging in as clusterJobRunner@remoteBox, and the other user will be logged in as someLocalUser@remoteBox. Is there a way to see if a remote user is actively using the box using either Python or Java?
How can I find out if someone is actively using a Linux computer in Python or Java?
11,510,091
1
2
1,087
0
java,python
In Java you can execute the users Linux command using Runtime.exec(), grab the standard output and get it into a parsable String. I don't think there are any OS-independent ways to do this.
0
1
0
1
2012-07-16T18:10:00.000
5
0.039979
false
11,510,032
0
0
0
2
I want to write a program that ssh's into remote boxes and runs jobs there if the remote computer is not actively being used. I'll be logging in as clusterJobRunner@remoteBox, and the other user will be logged in as someLocalUser@remoteBox. Is there a way to see if a remote user is actively using the box using either Python or Java?
Python os.getcwd() returns with tilde in the path. e.g. C:\MYFOLD~1\test
11,512,534
0
4
1,149
0
python,path,directory,tilde,getcwd
Try to use os.path.realpath, os.path.normpath.
0
1
0
0
2012-07-16T20:55:00.000
4
0
false
11,512,413
0
0
0
2
How can I get python to return the full pathname of C:\myfolderisafolder\test?
Python os.getcwd() returns with tilde in the path. e.g. C:\MYFOLD~1\test
11,523,138
0
4
1,149
0
python,path,directory,tilde,getcwd
You could just split the string with .split() at the tilde and then rejoin the full filepath with the .join() methods.
0
1
0
0
2012-07-16T20:55:00.000
4
0
false
11,512,413
0
0
0
2
How can I get python to return the full pathname of C:\myfolderisafolder\test?
Exposing commandline tools remotely to users
11,515,334
2
0
132
0
python,http,command-line,cgi
Are the teammates developers or comfortable with the command line? If so, I would propose SSH. Run SSHD on the box with the scripts. On Windows, this is easy with cygwin, otherwise it's there by default on Mac and Linux The client logs in (ssh user@host) and runs the script. Set up security with certificates and you won't even have to type your password. If there are problems, I would much rather be at the command line and able to debug the script than at the end of an opaque web page. Maintenance will be a lot easier too.
0
1
0
1
2012-07-17T00:44:00.000
2
0.197375
false
11,514,608
0
0
0
1
We've got a number of perl and python scripts we want to expose to some of our teammates for casual usage; and we really don't want ot deal with getting them setup with git, perl, python, dependencies, etc. One idea we had was to write a descriptor for each script as to what arguments it needed; and then let a simple HTML page call a CGI script with the appropriate arguments, wait and return stdout to the user. This seems such a simple need that I'm amazed that I can't find anything like it existing out there. No framework that renders out the form, that puts out a virtual console screen... There are, of course, major security concerns. Can anyone recommend a solution that does the above, or something else similar?
Waiting for a program to finish its task
11,518,020
1
0
220
0
python,process,applescript
I realized GUI applescript was the answer in this scenario. With it I could tell the PROCESS to get every window, and that worked. However, I'm leaving this up because I'd like to know other ways. I'm sure this GUI workaround won't work for everything.
0
1
0
0
2012-07-17T07:21:00.000
2
0.099668
false
11,517,743
0
0
0
1
I'd like to know how to have a program wait for another program to finish a task. I'm not sure what I'd look for for that... Also, I'm using a mac. I'd like to use Python or perhaps even applescript (I could just osascript python if the solution if for applescript anyway) Basically this program "MPEGstreamclip" converts videos, and it opens what appears to be 2 new windows while it's converting. One window is a conversion progress bar, and the other window is a preview of the conversion. (Not sure if these actually count as windows) (Also, MPEGstreamclip does not have an applescript dictionary, so as far as I know, it can't listen for certain window names existence) But basically I want my program to listen for when MPEGstreamclip is done, and then run its tasks. If it helps, when the conversion is done, the mpegstreamclip icon in the dock bounces once. I'm not sure what that means but I'd think you could use that to trigger something couldn't you? Thanks!
GoogleAppEngine error: rdbms_mysqldb.py:74
11,533,684
1
3
1,146
1
google-app-engine,python-2.7
it's been a while, but I believe I've previously fixed this by adding import rdbms to dev_appserver.py hmm.. or was that import MySQLdb? (more likely)
0
1
0
0
2012-07-17T10:25:00.000
3
0.066568
false
11,520,573
0
0
1
2
Trying to do HelloWorld on GoogleAppEngine, but getting the following error. C:\LearningGoogleAppEngine\HelloWorld>dev_appserver.py helloworld WARNING 2012-07-17 10:21:37,250 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded. Traceback (most recent call last): File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 133, in run_file(file, globals()) File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 129, in run_file execfile(script_path, globals_) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_main.py", line 694, in sys.exit(main(sys.argv)) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_main.py", line 582, in main root_path, {}, default_partition=default_partition) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3217, in LoadAppConfig raise AppConfigNotFoundError google.appengine.tools.dev_appserver.AppConfigNotFoundError I've found posts on GoogleCode, StackO regarding this issue. But no matter what I try, I still can't overcome this error. Python version installed on Windows 7 machine is: 2.7.3 GAE Launcher splash screen displays the following: Release 1.7.0 Api versions: ['1'] Python: 2.5.2 wxPython : 2.8.8.1(msw-unicode) Can someone help?
GoogleAppEngine error: rdbms_mysqldb.py:74
12,513,978
0
3
1,146
1
google-app-engine,python-2.7
just had the exact same error messages: I found that restarting Windows fixed everything and I did not have to deviate from the YAML or py file given on the google helloworld python tutorial.
0
1
0
0
2012-07-17T10:25:00.000
3
0
false
11,520,573
0
0
1
2
Trying to do HelloWorld on GoogleAppEngine, but getting the following error. C:\LearningGoogleAppEngine\HelloWorld>dev_appserver.py helloworld WARNING 2012-07-17 10:21:37,250 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded. Traceback (most recent call last): File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 133, in run_file(file, globals()) File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 129, in run_file execfile(script_path, globals_) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_main.py", line 694, in sys.exit(main(sys.argv)) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver_main.py", line 582, in main root_path, {}, default_partition=default_partition) File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3217, in LoadAppConfig raise AppConfigNotFoundError google.appengine.tools.dev_appserver.AppConfigNotFoundError I've found posts on GoogleCode, StackO regarding this issue. But no matter what I try, I still can't overcome this error. Python version installed on Windows 7 machine is: 2.7.3 GAE Launcher splash screen displays the following: Release 1.7.0 Api versions: ['1'] Python: 2.5.2 wxPython : 2.8.8.1(msw-unicode) Can someone help?
LINUX End of Line
11,520,748
1
0
409
0
python,linux,ascii,vi
The $ is displayed by vi (in certain modes). It is not in the file contents. You could use od -cx yourfile to check that.
0
1
0
1
2012-07-17T10:34:00.000
2
1.2
true
11,520,713
1
0
0
1
I am reading a ASCII file from LINUX(Debian) into Python CGI script where it is edited via a web page and then saved, If I use a graphical text editor the edited and un-edited file appear the same and are corectly formatted. Using vi the edited file contains ctrl M as the EOL marker and all lines rolled into one but the unedited file is correctly formatted. Using :set List in vi to see control characters the edited file remains as described above, but in the unedited file $ appears as EOL marker. I know LINUX EOL is ctrl 0x0D but what is the $? Why does $ format correctly and ctrl M does not?
When does the App Engine scheduler use a new thread vs. a new instance?
11,857,757
0
60
2,794
0
python,google-app-engine
If I set threadsafe: true in my app.yaml file, what are the rules that govern when a new instance will be created to serve a request, versus when a new thread will be created on an existing instance? Like people are saying here, if a previous instance is already using 10 threads, a new instance with a new thread would be initiated. A new thread will be created if all other threads are busy, they must be either waiting for some response or with computing results. If I have an app which performs something computationally intensive on each request, does multi-threading buy me anything? In other words, is an instance a multi-core instance or a single core? Now this question is very controversial. Everyone knows the answer but still they are skeptical. Multi-threading can never buy you any good if your task is based on just computations unless you're using a multi-core processor, don't ask me why a multi-core processor will help better, you know the answer. Now google app engine is not sophisticated enough to decide that when new threads should be dispatched to the other processor/core(if it exists), only new instances are dispatched to the other core/processor. Want your thread to run in the other core/processor? Well, throw some skills there and booya! Remember, it's upto you to decide if threads should run in other cores/processors, the engine can not take the responsibility for such because this could lead to so many confusions, the engine is not God. In short, by default the instance is single core, the engine can't decide for you when it should go multi-core. Or, are new threads only spun up when existing threads are waiting on IO? The first part of my answer clears this out. Yes, they only spun up when existing threads are busy, this is how threadsafe works, to prevent deadlocks. Now I can tell you this all, from my personal experience, I worked on the app engine for many months and programmed/debugged/tested apps that were highly dependent on the threadsafe architecture. If you want I can add references(I don't have references, just personal experience, but I'm ready to search and put things on the table for you), but I don't think they are needed in this case, threadsafe works in obvious ways which I have validated myself.
0
1
0
0
2012-07-17T15:23:00.000
3
0
false
11,525,717
1
0
1
1
If I set threadsafe: true in my app.yaml file, what are the rules that govern when a new instance will be created to serve a request, versus when a new thread will be created on an existing instance? If I have an app which performs something computationally intensive on each request, does multi-threading buy me anything? In other words, is an instance a multi-core instance or a single core? Or, are new threads only spun up when existing threads are waiting on IO?
How to set python environmental variables?
11,526,266
3
1
559
0
python,environment-variables
Err, the simple answer while trying to make this at least 30chars is - Yes. (It doesn't matter what it's set to, as long as it's set - although 1 would probably be reasonable). If you don't want to do it on a system level/user level basis, then you can always run python with the -B option.
0
1
0
0
2012-07-17T15:49:00.000
1
1.2
true
11,526,228
1
0
0
1
I would like to prevent python from automatically creating __pycache__ directories. From some searching, I have learned that I need to set the PYTHONDONTWRITEBYTECODE python environment variable. In a Windows environment, is this set the exact same way I would set any other system environmental variable (such as PATH)? If not, how can I set this variable so that any time I run python this is set?
MacPort: global does not accept --set
11,604,656
2
0
62
0
python,macports
-set is still there. The issue you have that you are missing a couple of arguments to the command. It should be sudo port select --set python python27 The port command takes an action and the one here is select. port select --set then takes as first argument the group it is select for in this case python.
0
1
0
0
2012-07-17T16:39:00.000
1
1.2
true
11,527,032
0
0
0
1
I am trying to change my default python to python27, I executed sudo port --set python27 but ended up with following error on my Mac Lion 10.7 Error: global does not accept --set. I was trying to see if MacPorts have deprecated the --set command and has introduced a new command instead. But I was unable to find anything related to that on their news website.
How to upgrade virtualenv to use a new system python?
11,528,399
1
2
2,650
0
python,virtualenv
You could try pip install -U python from within the virtual environment, not sure what it would break. You could also change the symlinks that point to the old Python, but not sure what side effects that would have. I would recommend the safest path, that is to first pip freeze > installed.txt and then recreate your virtualenv with your new Python and pip install -r installed.txt in it.
0
1
0
0
2012-07-17T18:07:00.000
3
0.066568
false
11,528,327
1
0
0
1
I had installed virtualenv on the system with python2.6. I upgraded the system python to 2.7, but the virtualenv still has affinity for python2.6. I tried easy_install --upgrade virtualenv, but that didn't change anything. Does anyone know how to update the system installed virtualenv to use the new python2.7 on the system?
How to get Django to use an updated python on Mac OS X server?
11,531,064
1
0
251
0
django,python-2.7,osx-server
Install it against the updated Python.
0
1
0
0
2012-07-17T21:18:00.000
2
0.099668
false
11,531,025
0
0
1
1
I am using Django on my Mac OS X server. Things are fine, so far. I have been using python 2.6.1 and all works well. I upgraded Python to version 2.7.3. Invoking python in the terminal brings up version 2.7.3, as expected. Checking Django using the {% debug %) reveals that Django is still using the original python 2.6.1 interpreter. On this system, /usr/local/bin contains a symlink to ../../../Library/Frameworks/Python.framework/Versions/2.7/bin/python In /usr/bin I find the python interpreter, and from that directory, invoking ./python gets python 2.6.1 running. My $PATH is /Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/mysql/bin:/usr/local/bin which I believe must have been altered on the python 2.7.3 install. What is considered the optimal way to get the command line and Django using the same Python? I am considering either moving the framework version to /usr/bin and sitting a symlink in the framework to the moved new version. On the system is also a /Library/Python directory, that contains the site-packages for versions 2.3, 2.5, and 2.6. In /Library/Python/2.6/site-packages are the major goodies django, mercurial, and south. Where are people putting things, nowadays? I mean, I know I could move things around, but I would like to anticipate where the Django project is going so future upgrades can go smoothly.
Eclpise and pyDev
11,579,758
0
0
86
0
python,eclipse,pydev
My guess is that the problem is that you're probably pointing to a shortcut and not the actual executable, so, can you check if you're really giving the executable (and not a shortcut) in the interpreter configuration process? If that's not the case, please post details you may have in your error log during that process.
0
1
0
0
2012-07-18T09:12:00.000
2
0
false
11,537,981
1
0
0
1
Possible duplicate but i couldn't find one. I've downloaded python and am having trouble loading it into eclipse, has anyone got a fool proof ground up solution that is garaunteed to work. This is what i've tried, Window--preferences--new--specified(Python 32) and C:\ directory file to python.exe but it keeps spitting out invalid interpreter.
Python path setting error with manage.py
11,550,187
1
1
1,723
0
python,django
Do not add #!/usr/bin/python . Use virtualenv and activate it before running python manage.py your_command . When you will be familiar with virtualenv try virtualenvwrapper.
0
1
0
0
2012-07-18T16:03:00.000
1
1.2
true
11,545,577
0
0
0
1
When I run ./manage.py, I get the following error, from: can't read /var/mail/os.path ./manage.py: line 4: import: command not found ./manage.py: line 7: syntax error near unexpected token `0,' ./manage.py: line 7: `sys.path.insert( 0, abspath( join( dirname( file ), 'external_apps' ) ) )' What is it!!! How can I resolve it?
Can I format the output of logger action of a content rule as CSV in Plone 4.1?
11,560,834
-1
1
85
0
python,plone
This can be achieved in two ways, these two methods are differentiated in Step 3: Step 1: Records are generally written in a line in zinstance.log. (There are some instances where it is written in multiple lines, so you need to handle exceptions). So here you can use readline function to read each record. Step 2: After reading record, and writing to respective places where ever you wnat using writelines. Step 3: After reading and writing records, now you have two choices: Method 1: You can copy the zinstance.log till whereever you have read to other location(subtitled with date and time, so that you will have logs always available) and create a new empty zinstance.log (Server will automatically write new logs to the new file, which will be available to you when ever you will run your program next time) at the location wherever it was. Method 2: You can also keep the pointer to the position, till wherever you have read, in a file, which is read next time you are running your program and start reading records from that position. This method may lead to unreliability, as if file size goes above the range of data type, then it will curropt the pointer till wherever you have read. Since log files are large enough, so its better not to take this approach Hope this will answer your concern
0
1
0
0
2012-07-19T11:20:00.000
1
-0.197375
false
11,559,752
0
0
1
1
I created a content rule to run a logger action, when a new content is added viz a file. When I run the view of the zinstance.log file,on linux I see all the logs. I wish to send the output for each logger action separately to another log file, so that it contains log concerned to that rule only where ever applicable in the Plone site. How can this be achieved. Is there any add-on for the same ? I know that we can grep the o/p and pipe it to a CSV for formatting it later.
Running python 3.2 programs from cygwin(windows 7 user)
11,573,304
0
1
319
0
python,python-3.x,cygwin
Ok.one solution i have found is that i can invoke cygwin through command window and then pass instructions using subprocess.However being able to run python 3.2 codes from cygwin would have been more preferable to me rather than the other way round!!
0
1
0
0
2012-07-19T13:18:00.000
3
0
false
11,561,744
1
0
0
1
I need to be able to run python 3.2 scripts from cygwin.However,the current setup of cygwin shows it isnt compatible with that.I searched on the internet and saw in some other forums that people have ben unable to do it.Anyone here has any idea how to do it?
site.addsitedir doesn't add egg to sys.path
11,576,705
2
0
3,434
0
python,pythonpath
If I set PYTHONPATH to contain that prefix's site-packages directory, the egg is added to sys.path and the module can be imported. Adding some directory to PYTHONPATH doesn't trigger processing of .pth-files in it. Therefore your zipped egg won't be in sys.path. You can import a module from the egg only if the egg itself is in sys.path (parent directory is not enough). If I instead from within the script run site.addsitedir with the prefix's site-packages directory, however, the egg is not added to sys.path and the module import fails. site.addsitedir() triggers processing of .pth-files if the directory hasn't been seen yet so it should work. The behavior you described is the opposite of what should happen. As a workaround you could add the egg to sys.path manually: sys.path.insert(0, '/path/to/the.egg')
0
1
0
1
2012-07-19T14:11:00.000
1
1.2
true
11,562,721
1
0
0
1
I have a python module packaged by distutils into a zipped egg installed in a custom prefix. If I set PYTHONPATH to contain that prefix's site-packages directory, the egg is added to sys.path and the module can be imported. If I instead from within the script run site.addsitedir with the prefix's site-packages directory, however, the egg is not added to sys.path and the module import fails. In both cases, the module's site-packages directory ends up in sys.path. Is this expected behavior? If so, is there any way to tell Python to process the .pth files in a given directory without setting an env var?
Getting jobs from beanstalkd - timed out exception
11,570,528
4
0
1,433
0
python,timeout,jobs,beanstalkd,beanstalkc
Calling beanstalk.reserve(timeout=0) means to wait 0 seconds for a job to become available, so it'll time out immediately unless a job is already in the queue when it's called. If you want it never to time out, use timeout=None (or omit the timeout parameter, since None is the default).
0
1
0
1
2012-07-19T18:53:00.000
1
1.2
true
11,567,431
0
0
1
1
I am using Python 2.7, beanstalkd server with beanstalkc as the client library. It takes about 500 to 1500 ms to process each job, depending on the size of the job. I have a cron job that will keep adding jobs to the beanstalkd queue and a "worker" that will run in an infinite loop getting jobs and processing them. eg: def get_job(self): while True: job = self.beanstalk.reserve(timeout=0) if job is None: timeout = 10 #seconds continue else: timeout = 0 #seconds self.process_job(job) This results in "timed out" exception. Is this the best practice to pull a job from the queue? Could someone please help me out here?
How to activate/deactivate a virtualenv from python code?
22,811,410
0
10
6,178
0
python,virtualenv
If you want to run a program outside of the virtualenv, just run your system python executable (e.g. /usr/bin/python) instead of the one in the virtualenv.
0
1
0
0
2012-07-20T05:13:00.000
4
0
false
11,573,261
1
0
0
3
For activation there is a script that activates a virtualenv from an already running python interpeter using execfile('C:/path/to/virtualev/Scripts/activate_this.py', dict(__file__='C:/path/to/virtualev/Scripts/activate_this.py')). However since I can still import packages that are not in the virtualenv from the current python script I am confused about how it works. For deactivation there is no python script at all. What should I do?
How to activate/deactivate a virtualenv from python code?
11,573,607
-3
10
6,178
0
python,virtualenv
This souds like bad idea. You are trying to modify environment of your script within this script. Please explain why? Can't you do it hierarchical? Use one script to run different scripts in different virtualenvs.
0
1
0
0
2012-07-20T05:13:00.000
4
-0.148885
false
11,573,261
1
0
0
3
For activation there is a script that activates a virtualenv from an already running python interpeter using execfile('C:/path/to/virtualev/Scripts/activate_this.py', dict(__file__='C:/path/to/virtualev/Scripts/activate_this.py')). However since I can still import packages that are not in the virtualenv from the current python script I am confused about how it works. For deactivation there is no python script at all. What should I do?
How to activate/deactivate a virtualenv from python code?
18,660,299
-4
10
6,178
0
python,virtualenv
at the command line, type the word 'deactivate'
0
1
0
0
2012-07-20T05:13:00.000
4
-1
false
11,573,261
1
0
0
3
For activation there is a script that activates a virtualenv from an already running python interpeter using execfile('C:/path/to/virtualev/Scripts/activate_this.py', dict(__file__='C:/path/to/virtualev/Scripts/activate_this.py')). However since I can still import packages that are not in the virtualenv from the current python script I am confused about how it works. For deactivation there is no python script at all. What should I do?
Python prevent os.getcwd() to give lower case results on windows using MKS shell
12,109,258
0
1
402
0
python,mks
Before starting Python and using os.getcwd(), in your console you probably used "cd c:\your_path". It matters if this 'c' is lower or upper.
0
1
0
0
2012-07-20T12:44:00.000
2
0
false
11,579,652
0
0
0
1
On Windows if i use MKS toolkit shell, os.getcwd() function returns value in lower case. However on using windows cmd, it returned exact path. Is it possible in Python by any means for os.getcwd() to return the exact path (without converting to lower case on Windows)?
GAE - Online admin console
11,595,724
0
0
172
0
python,google-app-engine
You can use remote shell, that is on your app engine sdk. For example ~/bin/google_appengine/remote_api_shell.py -s your-app-identifier.appspot.com s~your-app-identifier When you are inside the shell, you will have the db module enabled. in order to use your models, you will have to import them.
0
1
0
0
2012-07-21T05:55:00.000
2
0
false
11,589,862
0
0
1
1
Is there some way I can run custom python code on my google appengine app online? Is there a python console somewhere that I can use? I've seen vague references here and there, but nothing concrete.
Python: Hide sub-process print out on the terminal and continue the script while sub is running
39,337,469
0
0
665
0
python,debian,subprocess,scapy
In the spot where you put the command airodump-ng replace that part with timeout 'X's airodump-ng mon'X'
0
1
0
0
2012-07-21T07:19:00.000
2
0
false
11,590,258
0
0
0
1
is there a way to use python2.6 with either subprocess.Popen() or os.system() to run two tasks? Example the script will run "airodump-ng" first then this process is sub and is hidden(meaning will not print out from terminal) after which continue run the rest of the script which contain "sniff" function of scapy. I been researched but I only found windows version and python3. By the way I running on debian.
Writing a simple Mac App to start a python document
11,595,693
2
0
115
0
python,macos,terminal
Automator is great for this. Your one-line command, as an automator service, could be run from a keystroke. You can also make a terminal profile that runs the command when the profile is launched. You could also use applescript editor and make a (relatively simple) applescript that does the 'do script' command, to run your command. This gets you an .app. (A clickable launcher)
0
1
0
0
2012-07-21T09:41:00.000
1
0.379949
false
11,591,087
0
0
0
1
I am writing a Mac program in python that will run in terminal, and have a start.command file to start it up: #!/bin/bash cd "$(dirname "$0")" exec python "$(dirname "$0")/xavier_root/xavier_I-nil-nil.py" I was wondering though, if there would be a way to create a .app that would start up this program instead, so that I can put it on my dock. Is there any way I can do a simple app that would start up my start.command file, or perform the actions that my start.command file is doing?
keyboard interrupt doesn't stop my interpreter
11,592,469
6
1
6,153
0
python,terminal,osx-lion,infinite-loop
CTRL + Z sends to background, CTRL + C is to kill. However I am talking Linux here and Mac might be something different.
0
1
0
0
2012-07-21T13:05:00.000
1
1.2
true
11,592,433
0
0
0
1
I am testing a Log-parser that does a infinite loop (on purpose) with a cool down of 3 seconds every recurrence. Eventually I will link all the data to a GUI front-end so I can call a stop to the loop when the user is ready with parsing. The (small) problem now is, when testing the output in the Terminal (in OSX) when I do CTRL + Z to cancel the process my activity monitor keeps showing the process as active (probably because of the loop?). So the question: How can I call (without extra non-native libraries, if possible) to stop the whole process when calling a CTRL + Z in Terminal? When I quit the Terminal, all python processes get killed, but I would like to know how to do it while the Terminal is still running :).
How to write tests for static routes defined in app.yaml?
11,600,406
1
1
120
0
python,unit-testing,google-app-engine
I have a post deploy script for the staging environment that just does curl on the urls to validate they are all there. If this script passes (among other things) I will deploy from staging to production.
0
1
0
1
2012-07-22T12:39:00.000
1
0.197375
false
11,600,374
0
0
1
1
I have quite a few static files used in my Google App Engine application (CSS, robots.txt, etc.) They are all defined in app.yaml. I want to have some automated tests that check whether those definitions in app.yaml are valid and my latest changes didn't brake anything. E.g. check that specific URLs return correct responses. Ideally, it should be a part of my app unit tests.
check to see if a directory is valid in Python
26,087,266
-1
3
4,550
0
python,windows,linux,directory
if you use os.path.join to create the directory string you will correctly writes the path depending on the environment you are in. then you can use os.path.isdir, as suggested above. to verify if the string points to an existing directory
0
1
0
0
2012-07-22T21:52:00.000
3
-0.066568
false
11,604,256
1
0
0
1
I have a program in python 2.7 that is writing certain files and directories base on user input. I need to make sure that the files and directories are valid for both linux and windows as the files will be exchanged through the two operating systems. The files will originally be created in linux and manual moved to windows. I have checked through Python docs, stack exchange, and several pages of google without turning up any usable information which is strange because I would imagine this would be a fairly common issue. Is there an easy solution? Edit: I would like to validate the directory-filename incase a user enters a path that does not work for linux or windows. As an example if a user enters "Folder1/This:Error/File.txt" the program will see this as an error. The program will run in Linux and write the files in linux but later the files will be moved to windows. The differences in forward/back-slashes is a non-issue, but other characters that may work for linux but not windows would present a problem. Also, often times the files or directories will not be present (as they are about to be created) so I need to check that path, held in a string, would be a valid path.
Running python script in Blender
12,752,197
0
40
87,536
0
python,blender
It is likely that drawcar.py is trying to perform pyOpenGL commands inside Blender, and that won't work without modification. I suspect you are getting some import errors too (if you look at the command console). Blender has it's own internal python wrapper for opengl called bgl, which does include a lot of the opengl standards, but all prefixed by bgl. If you have a link to drawcar.py I can have a look at it and tell you what's going on.
0
1
0
0
2012-07-22T22:38:00.000
5
0
false
11,604,548
0
0
0
1
I installed Blender 2.6 and I'm trying to run a script called drawcar.py (Which uses PyOpenGL) I looked around the documentation for importing a script and could only access Blender's python console. How do I run drawcar.py from the Linux terminal with Blender?
ClientDC and WindowDC do not draw under Fedora 16 Gnome 3, only PaintDC
11,617,941
1
0
76
0
linux,wxpython,fedora,gnome-3,gdi
I think the recommended way to paint is with the newer wx.GCDC with a fallback to the wx.PaintDC. If you need advanced drawing, see FloatCanvas, cairo or the glcanvas.
1
1
0
0
2012-07-23T06:42:00.000
1
0.197375
false
11,607,571
0
0
0
1
I am writing an app which draws text and shapes in a ClientDC of a Frame. When I run the app under my Fedora 16(Gnome 3) nothing is drawn in the Frame, but if I run it under Windows all drawings display normally. I've tried using WindowDC to do the drawing on, but it is not different to ClientDC under Fedora. I can only get a successful drawing when using PaintDC. Am I doing something wrong(or missing something), or is it just Linux/Fedora/Gnome 3?
python or bash script that does something when there is no response(output)
11,611,070
0
0
124
0
python,bash
In a Bash-script, you could redirect the output to a file, and if the length of the file is zero then there was no output.
0
1
0
0
2012-07-23T10:45:00.000
3
0
false
11,611,002
0
0
0
1
There is an external program A. I want to write a script that does some action if the called external program A does not bring up any output(stout). How is this possible in bash or python?
Keep cmd.exe open
11,628,345
1
6
5,043
0
python,registry,cmd
Either right-click your script and remove Program->Close on exit checkbox in its properties, or use cmd /k as part of its calling line. Think twice before introducing artificial delays or need to press key - this will make your script mostly unusable in any unattended/pipe calls.
0
1
0
0
2012-07-24T09:23:00.000
5
0.039979
false
11,627,846
1
0
0
2
I have a python script which I have made dropable using a registry-key, but it does not seem to work. The cmd.exe window just flashes by, can I somehow make the window stay up, or save the output? EDIT: the problem was that it gave the whole path not only the filename.
Keep cmd.exe open
11,628,145
1
6
5,043
0
python,registry,cmd
Another possible option is to create a basic TKinter GUI with a textarea and a close button. Then run that with subprocess or equiv. and have that take the stdout from your python script executed with pythonw.exe so that no CMD prompt appears to start with. This keeps it purely using Python stdlib's and also means you could use the GUI for setting options or entering parameters... Just an idea.
0
1
0
0
2012-07-24T09:23:00.000
5
0.039979
false
11,627,846
1
0
0
2
I have a python script which I have made dropable using a registry-key, but it does not seem to work. The cmd.exe window just flashes by, can I somehow make the window stay up, or save the output? EDIT: the problem was that it gave the whole path not only the filename.
Basic Terminal emulation in python
11,698,801
1
4
6,899
0
python,shell,terminal,blender
It seems that you should run it on new control terminal, allocated with "forkpty". To suppress the warning "no job control ...", you need to call "setsid".
0
1
0
0
2012-07-24T15:50:00.000
3
0.066568
false
11,634,626
0
0
0
1
I've been trying to write a basic terminal emulation script, because for some reason i've got no terminal access on my mac. But to write game engine scripts in blender the console, which usually opens in the terminal you started blender with, is crucial. For just doing simple things like deleting, renaming etc. I used to execute commands using stream = os.popen(command) and then print (stream.read()). That works fine for most things but not for anything interactive. Shortly i've discovered a new way: sp = subprocess.Popen(["/bin/bash", "-i"], stdout = subprocess.PIPE, stdin = subprocess.PIPE, stderr = subprocess.PIPE) and then print(sp.communicate(command.encode())). That should spawn an interactive shell that i can use like a terminal, doesen't it? But either way i can't keep the connection open, and using the last example I can call sp.communicate once, giving me the following output(in this case for 'ls /') and some errors: (b'Applications\n[...]usr\nvar\n', b'bash: no job control in this shell\nbash-3.2$ ls /\nbash-3.2$ exit\n'). The second time it gives me a ValueError: I/O operation on closed file. Sometimes (like for 'ls') I only get this error: b'ls\nbash-3.2$ exit\n'. What does that mean? How can i emulate a terminal with python that allows me to control an interactive shell or run blender and communicate with the console?