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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
What is the best Google App Engine blobstore workflow?
| 4,775,721
| 0
| 3
| 681
| 0
|
python,google-app-engine,forms,file-upload,blobstore
|
The solution I've come up with for this is not the prettiest but it gets the job done. On the upload view (view that is specified in the create_upload_url function) I'm passing the post variables to the same form class from the first page. If the form is valid I'm saving the variables along with the BlobInfo.key to the model. If it is not a valid form I'm saving the errors in memcache and redirecting back to the first page with the variable of error that triggers the view to retrieve the errors from memcache and add them to the form instance.
So again here's the steps.
Create form view
Check POST variables with the same form from the first view
If the form is valid save it along with the BlobInfo.key, if not save errors to memcache with a small lifespan and redirect to first view with the memcache key in the url
Retrieve the form errors from memcache and add them to the new form instance
Resubmit the form with errors fixed and save
| 0
| 1
| 0
| 0
|
2011-01-21T21:46:00.000
| 1
| 0
| false
| 4,764,129
| 0
| 0
| 1
| 1
|
What is the best workflow for uploading file to the blobstore while saving information about the blob and other fields to a model record?
For example, should I submit the form to the blobstore upload url (blobstore.create_upload_url), clean the form, redirect if errors and save and redirect if not?
What is the best way to pass the errors back? GET variables? I tried using models to the save the form errors and redirecting based on the form error model instance, but that was messy. Any ideas?
|
Good way to generate GUIDs on app engine?
| 4,764,511
| 0
| 8
| 3,107
| 0
|
python,google-app-engine,guid
|
Any chance they are guid's for things you're storing in the datastore?
If so, I believe object.key is a GUID
| 0
| 1
| 0
| 0
|
2011-01-21T22:26:00.000
| 5
| 0
| false
| 4,764,474
| 0
| 0
| 1
| 1
|
I was wondering if anyone knows of a good way to generate GUIDs on python google app engine. I feel like there is a simple way that people are using, what would you suggest.
|
Install packages to Python2.6
| 4,775,706
| 2
| 1
| 3,008
| 0
|
python,centos
|
python-devel won't help you, since it will only be available for 2.4. You will need to install the package from source with the appropriate version of Python, e.g. python2.6 setup.py install.
| 0
| 1
| 0
| 0
|
2011-01-23T15:09:00.000
| 5
| 1.2
| true
| 4,774,505
| 1
| 0
| 0
| 2
|
I've just installed Python2.6 on CentOS 5. I have to type python26 to run it. If I type python I get the default Python 2.4.
Now I need to build a package using python2.6, but it fails because it can't find python-devel. I know python-devel is installed for Python 2.4. How do I install python-devel (or other packages) specifically for Python 2.6?
EDIT
I know on WebFaction they have easy_install2.6 to do this type of thing.
|
Install packages to Python2.6
| 4,774,534
| 0
| 1
| 3,008
| 0
|
python,centos
|
You can install a specific version of the package, such as:
yum install python-devel-2.6.2-5.el6.i686
I don't know the exact package version, depends on your CentOS version.
| 0
| 1
| 0
| 0
|
2011-01-23T15:09:00.000
| 5
| 0
| false
| 4,774,505
| 1
| 0
| 0
| 2
|
I've just installed Python2.6 on CentOS 5. I have to type python26 to run it. If I type python I get the default Python 2.4.
Now I need to build a package using python2.6, but it fails because it can't find python-devel. I know python-devel is installed for Python 2.4. How do I install python-devel (or other packages) specifically for Python 2.6?
EDIT
I know on WebFaction they have easy_install2.6 to do this type of thing.
|
Easiest way to share work between backend and front end
| 4,777,646
| 1
| 1
| 181
| 0
|
python,django,installation
|
Get him to set up a virtual machine on his Mac, using VMWare Fusion or Parallels, running the same operating system that you currently use for your back end. If he prefers developing using Mac tools he can do still that by sharing his local changes to the virtual machine via a shared directory.
| 0
| 1
| 0
| 0
|
2011-01-23T23:25:00.000
| 3
| 0.066568
| false
| 4,777,262
| 0
| 0
| 1
| 2
|
Hey everyone,
I am expanding my team and I have recently added an additional front end engineer on my site. I am currently using django to run my site but my site is using a lot of plugins, namely: django-celery, django-mailer, django-notification, and django-socialregistration.
Let me describe my situation:
He is using Mac OS X, and I have no experience in installing stuff on mac os X or configuration on that platform
I believe that getting my backend to run on his computer might be somewhat troublesome, i.e. I have to install a bunch of plugins (which are not available on pip or easy_install as they are the latest version) and I have also made heavy modification to django-socialregistration which I am currently using by symlinking to the modified code in my repos in my python path
I tried to look into solutions like pip and easy_install but I have not been able to get them to install code from github
I think the easiest way is to get my backend working on his computer and then he just commiting to the repos. Any ideas how I can make this easy?
|
Easiest way to share work between backend and front end
| 4,777,381
| 0
| 1
| 181
| 0
|
python,django,installation
|
An alternative, if that's possible, would be to set up a testing/development environment on a machine with an OS you're familiar with, then install something like Dropbox on his local machine where he can develop the frontend code, and install Dropbox on that other environment with the backend components. Dropbox would sync his local changes to that testing environment for him to run the code on.
That way, he would be able to use that environment to test his code, you wouldn't need to set up a backend on his machine (or keep it up to date) and you'd still be getting the same functionality.
Again, if that's an option.
| 0
| 1
| 0
| 0
|
2011-01-23T23:25:00.000
| 3
| 0
| false
| 4,777,262
| 0
| 0
| 1
| 2
|
Hey everyone,
I am expanding my team and I have recently added an additional front end engineer on my site. I am currently using django to run my site but my site is using a lot of plugins, namely: django-celery, django-mailer, django-notification, and django-socialregistration.
Let me describe my situation:
He is using Mac OS X, and I have no experience in installing stuff on mac os X or configuration on that platform
I believe that getting my backend to run on his computer might be somewhat troublesome, i.e. I have to install a bunch of plugins (which are not available on pip or easy_install as they are the latest version) and I have also made heavy modification to django-socialregistration which I am currently using by symlinking to the modified code in my repos in my python path
I tried to look into solutions like pip and easy_install but I have not been able to get them to install code from github
I think the easiest way is to get my backend working on his computer and then he just commiting to the repos. Any ideas how I can make this easy?
|
using python 2.6?
| 4,778,706
| 4
| 5
| 657
| 0
|
python
|
2.6 will be around for a long time. There are many machines that still run even 2.4, so you're fine.
| 0
| 1
| 0
| 0
|
2011-01-24T04:35:00.000
| 4
| 0.197375
| false
| 4,778,679
| 1
| 0
| 0
| 2
|
i have no way of upgrade to python 2.7 or 3.1 so i am stuck with python 2.6 on my ubuntu 10.04 machine.
will i still be able to find host that supports python 2.6?
is using python 2.6 still consider outdated or bad practice?
|
using python 2.6?
| 4,778,746
| 3
| 5
| 657
| 0
|
python
|
Python 2.6 will probably still be around for a while, as Python 2.7 was released only a few months ago.
You can always use from __future__ import ... to make use of some of the newer features from Python 3.x
| 0
| 1
| 0
| 0
|
2011-01-24T04:35:00.000
| 4
| 0.148885
| false
| 4,778,679
| 1
| 0
| 0
| 2
|
i have no way of upgrade to python 2.7 or 3.1 so i am stuck with python 2.6 on my ubuntu 10.04 machine.
will i still be able to find host that supports python 2.6?
is using python 2.6 still consider outdated or bad practice?
|
Python Console UI Suggestions
| 5,085,080
| 4
| 11
| 1,317
| 0
|
python,console-application,curses,urwid
|
urwid is a very complete UI interface and you can do almost everything. In fact, I'm developing an app using urwid. But, as Paulo Scardine said, dialog is a better choice for a wizard-like app.
| 0
| 1
| 0
| 0
|
2011-01-24T14:44:00.000
| 2
| 0.379949
| false
| 4,783,308
| 0
| 0
| 0
| 2
|
I'm currently rewriting a perl console application that was using curses, and planning to implement it in Python. So far I've narrowed my library options to straight curses, urwid, and dialog.
The application is basically an installer for an appliance that will accommodate basic configuration (network options, hostname, etc). Are there any suggestions or advocates for one of these over the other? Any serious limitations with urwid or dialog?
|
Python Console UI Suggestions
| 4,783,572
| 2
| 11
| 1,317
| 0
|
python,console-application,curses,urwid
|
Dialog is very easy to use and a good choice for an installer using 'wizard-like' interface.
| 0
| 1
| 0
| 0
|
2011-01-24T14:44:00.000
| 2
| 0.197375
| false
| 4,783,308
| 0
| 0
| 0
| 2
|
I'm currently rewriting a perl console application that was using curses, and planning to implement it in Python. So far I've narrowed my library options to straight curses, urwid, and dialog.
The application is basically an installer for an appliance that will accommodate basic configuration (network options, hostname, etc). Are there any suggestions or advocates for one of these over the other? Any serious limitations with urwid or dialog?
|
Running a Twisted Application in PyDev
| 4,871,001
| 3
| 3
| 2,436
| 0
|
python,eclipse,pydev,twisted.application
|
First off, thank you all so much for your kind and gracious support in this matter!
The key to running a twisted application via the PyDev module of Eclipse is to define twistd.py as the Main Module in the Run Configuration. The following steps can be used:
These instructions assume you can already run twisted applications on your system, which means you've installed zope and twisted. For example, the following already works for you:
python twistd.py mytwistapp.tac
These instructions also assume that you have already installed and configured PyDev in Eclipse, including the definition of the PYTHONPATH.
1. Navigate to Window -> Preferences -> PyDev -> Interpreter (Python)
2. Under Libraries Tab (System PYTHONPATH), System Libs should already contain location of your Python instllation (e.g., c:\python26, c:\python26\dlls\, c:\python26\lib, etc).
3. Add the Zope egg and the Twisted folder to System libs. For example, c:\python26\lib\site-packages\twisted and c:\python26\lib\site-packages\zope.interfaces-3.6.1-py2.6-win32.egg
Create a new Pydev project
Create a new PyDev project (e.g., MYPROJ)
Import your various twisted application files
* Add twistd.py to your project *. Rather than adding a copy of the file to my project I linked to the existing file (File -> New -> File -> Advanced -> "Link to file in the file system" -> c:\python26\scripts\twistd.py). This is key as you will use twistd.py to run your application from within Eclipse.
Now that your project is setup, create a new Run Configuration.
Run -> Run Configurations
Use the following values under the Main Tab
Name: Twisted (or whatever)
Project: MYPROJ
Main Module: ${workspace_loc:MYPROJ/twistd.py}
Use the following values under the Arguments Tab
Program Arguments: -ny ${workspace_loc:MYPROJ/mytwistapp.tac}
And that's it! The key is importing twistd.py as the Main Module, which then allows the program arguments to be passed into twsttd.py, just as you would do from the command line.
| 0
| 1
| 0
| 0
|
2011-01-25T14:34:00.000
| 1
| 0.53705
| false
| 4,794,707
| 0
| 0
| 0
| 1
|
I would like to debug a Twisted Application (10.0.0) using the Eclipse (3.5.2) PyDev Module (1.6.4) and Python (2.6.5). To run the application from the command line I would specify the following:
c:\python26\python c:\python26\scripts\twistd.py -ny mytwistedapp.py
To accomplish this using PyDev I created a new PyDev project and imported mytwistedapp.py and twistd.py. Under the project's run configuration I specified c:\python26\scripts\twistd.py as the main module. If I select Run -> Debug Configurations it runs twistd.py with no parameters (half-way there, right?). If I try to add the program arguments to the run configuration (-ny mytwistedapp.py) they are processed by the PyDev debugger instead of twistd.py. Two questions:
Is specifying twistd.py as the main module the right approach?
If so, how can I pass twistd.py the parameters it needs to run mytwistedapp.py (-ny mytwistedapp.py)?
|
twisted.pair.ethernet vs iptables
| 4,799,871
| 1
| 0
| 441
| 0
|
python,ethernet,iptables
|
twisted.pair.ethernet will give you a little bit of the parsing, but it doesn't do anything for actually getting the data in the first place, nor putting it back on the network (if you don't filter it out). For that you need to talk to the tuntap system, which Twisted doesn't do anything with.
| 0
| 1
| 0
| 0
|
2011-01-25T20:42:00.000
| 1
| 1.2
| true
| 4,798,596
| 0
| 0
| 0
| 1
|
I need to implement some low-level IP filtering/tracking. Typically I would use iptables for this, but since I am currently using twisted in a few projects I'd consider using it's ethernet library, if it's possible. Actually, I would prefer it (it's easier to deploy than iptables rules).
Is it possible to use twisted python's twisted.pair.ethernet to implement a partial analog of iptables?
|
How do I install a user-specific configuration file with the distribute python
| 4,799,345
| 5
| 1
| 304
| 0
|
python,configuration-files,distribute
|
Since the egg is hard to edit, it doesn't go in the egg.
A user-editable configuration file goes in the user's HOME directory or a system-wide directory like /etc/myapp.
Your app should search in a number of easy-to-find places. Follow the Linux guidelines for tracking down the .bashrc file for hints on how best to do this. Or Follow the Windows guidelines on System and My Documents directoryes.
You write your app in one of two ways.
It can work with no config. If -- after searching all the usual places -- there's no config, it still works.
It creates an default config in the current working directory if it can't find one anywhere else.
| 0
| 1
| 0
| 0
|
2011-01-25T21:55:00.000
| 2
| 1.2
| true
| 4,799,298
| 1
| 0
| 0
| 1
|
I'm creating a python package, and using distribute to package it as an egg. I'd like to install a user-editable configuration file for each user of my software. What is the best way to accomplish this? I'm using Python 2.6 and am targeting the Windows platform.
|
How do I flush everything from Celery?
| 4,803,074
| 7
| 2
| 724
| 0
|
python,django,celery
|
Have you tried to restart the celery service with --discard parameter ?
| 0
| 1
| 0
| 0
|
2011-01-26T09:09:00.000
| 1
| 1.2
| true
| 4,802,807
| 0
| 0
| 1
| 1
|
I accidently added too many things to the queue, and now it froze.
Can't get it to do anything else.
|
Automatic indexes for expando properties in the google app engine for python
| 4,812,503
| 4
| 3
| 663
| 0
|
python,google-app-engine,expando
|
All properties are automatically indexed for simple queries. Simple queries, in this case, are those that either:
Use only equality filters, with no sort orders or inequality filters.
Have an inequality filter or sort order on a single field, with no other filters.
If you want to do more complex queries - such as ones that mix inequality and equality filters, only then do you need to build a custom index.
It's not possible to build custom indexes at runtime. If you want to use expandos, you need to make sure that you restrict the queries you execute to those that are satisfiable under one of the situations above.
| 0
| 1
| 0
| 0
|
2011-01-26T17:46:00.000
| 1
| 1.2
| true
| 4,807,957
| 0
| 0
| 1
| 1
|
The google app engine python sdk offers an Expando type object which can be used for adding dynamic properties to an object that can be persisted to the datastore.
The app engine also requires that for any property on which the objects need to be searched or sorted, an index must be created before uploading the app to google's servers. This is really strange because it means that i am supposed to know before hand what properties my users will create on my objects. If i knew that in advance, why would i not define them as static properties in my existing model?
Does anyone know how to automatically create indexes for dynamic properties of Expando models after uploading to the app engine? If not, can anyone tell me why does the gae tout Expando as dynamic construct when it can not let you create new properties that can be searched on or sorted by, only properties that arent searchable or sortable.
|
How to fetch environment variables in Mac OS X using python?
| 4,808,924
| 1
| 3
| 9,575
| 0
|
python,macos,environment-variables,.profile
|
You can also the helper function os.getenv(varname[, value]) which will return the value of environment variable varname, and if it not present will return value which defaults to None
| 0
| 1
| 0
| 0
|
2011-01-26T19:08:00.000
| 4
| 0.049958
| false
| 4,808,809
| 1
| 0
| 0
| 2
|
How can I lookup environment variables (e.g. export HG_USER from .profile) using python code in Mac OS X?
|
How to fetch environment variables in Mac OS X using python?
| 4,808,824
| 11
| 3
| 9,575
| 0
|
python,macos,environment-variables,.profile
|
os.environ is a dictionary containing all the environment variables. You need to import os before you can use it.
So, for example HG_USER would be accessed by os.environ['HG_USER'].
| 0
| 1
| 0
| 0
|
2011-01-26T19:08:00.000
| 4
| 1.2
| true
| 4,808,809
| 1
| 0
| 0
| 2
|
How can I lookup environment variables (e.g. export HG_USER from .profile) using python code in Mac OS X?
|
How can I profile pure dll?
| 4,809,972
| 1
| 2
| 1,019
| 0
|
c++,python,dll,profiling
|
You can't profile code that isn't running- that's the definition of profiling. You will need to build something that can run (an executable file) that links to the DLL and use that.
| 0
| 1
| 0
| 0
|
2011-01-26T20:58:00.000
| 2
| 0.099668
| false
| 4,809,950
| 0
| 0
| 0
| 2
|
I have project that creates dlls. These dlls are invoked from python later by special plugin system blue-sky. So in this project it's very hard to build executable file, but I need profiling. Are there any profilers that can work with pure dlls?
I've tried Intel Amplifier, Microsoft VS2008 profiler they don't work. I've also tried Very Sleepy but its features are limited.
|
How can I profile pure dll?
| 4,810,355
| 1
| 2
| 1,019
| 0
|
c++,python,dll,profiling
|
If your dll is loaded by Python then you need to profile the Python process. With the Microsoft profiler as long as all the .pdb files are present it should resolve symbols within the dll. Another option is to create an executable that loads and calls the functions you're interested in and then profile said executable.
E.g. You may have a "python.exe" process that is running your python program which is loading the .dll and you can attach the visual studio command line profiler to it by:
vsperfcmd /attach:"python.exe"
| 0
| 1
| 0
| 0
|
2011-01-26T20:58:00.000
| 2
| 1.2
| true
| 4,809,950
| 0
| 0
| 0
| 2
|
I have project that creates dlls. These dlls are invoked from python later by special plugin system blue-sky. So in this project it's very hard to build executable file, but I need profiling. Are there any profilers that can work with pure dlls?
I've tried Intel Amplifier, Microsoft VS2008 profiler they don't work. I've also tried Very Sleepy but its features are limited.
|
Difference between subprocess.Popen and os.system
| 4,813,317
| 67
| 166
| 139,683
| 0
|
python,subprocess,system
|
subprocess.Popen() is strict super-set of os.system().
| 0
| 1
| 0
| 0
|
2011-01-27T06:04:00.000
| 5
| 1
| false
| 4,813,238
| 0
| 0
| 0
| 1
|
What is the difference between subprocess.Popen() and os.system()?
|
Remove dock icon for shell executable in Mac OS X?
| 25,462,666
| 0
| 0
| 1,221
| 0
|
python,macos,dock,cx-freeze
|
My app has some helper command-line tools in one of its frameworks. If the tools are stored in the framework’s executable directory, Mac OS X wants to show them in the Dock. Since the tools run quickly, this appears as a brief flash where all the other Dock icons move to make space for the new icon and then move back.
To fix this, I am setting LSBackgroundOnly to true in the Info.plist. LSUIElement would probably also work. Since a command-line tool is just a single file, the way that you set the Info.plist is to have a separate file that Xcode embeds in the binary. You can set this by adding -sectcreate __TEXT __info_plist $(INFOPLIST_FILE) to the OTHER_LDFLAGS build setting. (Hopefully there is a Makefile line or equivalent where you can set this for cx_freeze.)
| 0
| 1
| 0
| 0
|
2011-01-27T10:52:00.000
| 2
| 0
| false
| 4,815,384
| 0
| 0
| 0
| 2
|
I know you can remove the dock icon for an app by setting LSUIELEMENT = 1. I have an executable created by cx_freeze, which bundles a set of Python scripts into a single executable. How can I remove the dock icon, with or without using AppleScript?
|
Remove dock icon for shell executable in Mac OS X?
| 4,815,469
| 0
| 0
| 1,221
| 0
|
python,macos,dock,cx-freeze
|
Ordinary executables (i.e. command line tools) do not show up in the dock.
| 0
| 1
| 0
| 0
|
2011-01-27T10:52:00.000
| 2
| 0
| false
| 4,815,384
| 0
| 0
| 0
| 2
|
I know you can remove the dock icon for an app by setting LSUIELEMENT = 1. I have an executable created by cx_freeze, which bundles a set of Python scripts into a single executable. How can I remove the dock icon, with or without using AppleScript?
|
dev_appserver.py doesn't recognize my files
| 14,570,507
| 2
| 1
| 2,131
| 0
|
python,google-app-engine
|
I had the same problem.
Adding python.exe in front of dev_appserver.py solved the problem for me.
c:\Programme\Python27\python.exe C:\Programme\Google\AppEngineSDK\google_appengine\dev_appserver.py MoviesBwu\
| 0
| 1
| 0
| 0
|
2011-01-28T00:17:00.000
| 3
| 0.132549
| false
| 4,823,466
| 0
| 0
| 1
| 1
|
I'm trying to get a basic GAE tutorial to work with Windows 7.
So far I have:
Installed python 2.5.4
Installed the current GAE SDK
Set my PATH varible to include python and the GAE
Created a "hello, world" app with an app.yaml and main.py file as specified.
When I call dev_appserver.py . in my app's directory or dev_appserver.py DIRECTORY_NAME one directory above my app, I receive the error message:
Invalid arguments
Application root must be the path to
the application to run in this server.
Must contain a valid app.yaml or
app.yml file.
[A bunch of dev_appserver.py option
follow this]
What am I doing wrong? and as far as I can tell, I've correctly configured everything.
|
Inside python code, how do I run a .sh script?
| 4,826,733
| 1
| 5
| 32,061
| 0
|
python,bash,shell
|
You can use os.system or subprocess.Popen or subprocess.call but when using subprocess methods make sure you use shell=True. And executing it via system call in all these methods is blocking. The python script will complete and then go the next step.
| 0
| 1
| 0
| 1
|
2011-01-28T09:36:00.000
| 3
| 0.066568
| false
| 4,826,686
| 1
| 0
| 0
| 1
|
Will it continue the code after it's run? Or will it stop at that line until the script is done?
|
Override file operations in Python
| 4,835,903
| 0
| 2
| 1,152
| 0
|
python,filesystems
|
If you want to write the code of your own file system from scratch, one way or another you will end up rewriting a library.
I have no knowledge of any library implementing an in-memory temporary file system in pure Python. As an alternative, in Linux you can use the tmpfs file system, usually mounted on /dev/shm. You can open, read and write files there as usual.
| 0
| 1
| 0
| 0
|
2011-01-29T06:56:00.000
| 4
| 0
| false
| 4,835,603
| 1
| 0
| 0
| 3
|
Is there a way to override all file operations in Python? File operations such as 'open', 'os.rename' and 'os.unlink'.
I want to create a temporary, in-memory file system without rewriting a library. Does anyone know of a script or a library that has this feature? I want to run a library on Google App Engine and it is not possible to write to the file system.
|
Override file operations in Python
| 4,835,941
| 0
| 2
| 1,152
| 0
|
python,filesystems
|
I found this which may be close enough to do the job code.google.com/p/pyfilesystem
| 0
| 1
| 0
| 0
|
2011-01-29T06:56:00.000
| 4
| 0
| false
| 4,835,603
| 1
| 0
| 0
| 3
|
Is there a way to override all file operations in Python? File operations such as 'open', 'os.rename' and 'os.unlink'.
I want to create a temporary, in-memory file system without rewriting a library. Does anyone know of a script or a library that has this feature? I want to run a library on Google App Engine and it is not possible to write to the file system.
|
Override file operations in Python
| 4,835,828
| 1
| 2
| 1,152
| 0
|
python,filesystems
|
"Override"? That word doesn't really make any sense in that context. You can replace them in various ways, depending on what you want really.
Making a in memory file system can be done on most OS's through the operating system, like with tmpfs in most Unices. That's probably a better solution for you.
| 0
| 1
| 0
| 0
|
2011-01-29T06:56:00.000
| 4
| 0.049958
| false
| 4,835,603
| 1
| 0
| 0
| 3
|
Is there a way to override all file operations in Python? File operations such as 'open', 'os.rename' and 'os.unlink'.
I want to create a temporary, in-memory file system without rewriting a library. Does anyone know of a script or a library that has this feature? I want to run a library on Google App Engine and it is not possible to write to the file system.
|
[Errno 32]Broken pipe in Python Script in Crontab
| 4,851,152
| 1
| 2
| 1,316
| 0
|
python
|
Hi I dnt know y the error occurs but when i directed the print statements from my script to another file this error did not come and my script ran successfully
Example: Myscript.py > test.log
| 0
| 1
| 0
| 1
|
2011-01-29T10:49:00.000
| 1
| 0.197375
| false
| 4,836,450
| 0
| 0
| 0
| 1
|
I am running a Python script which downloads PDF files from the FTP. The script when run manually works perfectly but when i put it in crontab in my ubuntu machine and execute it i get a an error [Errno 32] Broken pipe. Any idea why this happens and how do i handle this?
|
STDIN or file as mapper input in Hadoop environment?
| 4,839,045
| 1
| 1
| 3,305
| 0
|
python,hadoop,mapreduce
|
Hadoop streaming has to take input from STDIN. I think the confusion you're having is you're trying to write code to do some of the things that Hadoop Streaming is doing for you. I did that when I first started Hadooping.
Hadoop streaming can read in multiple files and even multiple zipped files which it then parses, one line at a time, into the STDIN of your mapper. This is a helpful abstraction because you then write your mapper to be file name/location independent. You can then use your mappers and reducers for any input which is handy later. Plus you don't want your mapper trying to grab files because you have no way of knowing how many mappers you will have later. If files were coded into the mapper, then if a single mapper failed you would never get output from the files hard coded in that mapper. So let Hadoop do the file management and have your code be as generic as possible.
| 0
| 1
| 0
| 0
|
2011-01-29T16:48:00.000
| 1
| 0.197375
| false
| 4,838,074
| 0
| 0
| 0
| 1
|
As we need to read in bunch of files to mapper, in non-Hadoop
environment, I use os.walk(dir) and file=open(path, mode) to read in
each file.
However, in Hadoop environment, as I read that HadoopStreaming convert
file input to stdin of mapper and conver stdout of reducer to file
output, I have a few questions about how to input file:
Do we have to set input from STDIN in mapper.py and let
HadoopStreaming convert files in hdfs input directory to STDIN?
If I want to read in each file separately and parse each line, how
can I set input from file in mapper.py?
My previous Python code for non-Hadoop environment sets:
for root, dirs, files in os.walk('path of non-hdfs')
.....
However, in Hadoop environment, I need to change 'path of non-hdfs' to
a path of HDFS where I copyFromLocal to, but I tried many with no
success, such as os.walk('/user/hadoop/in') -- this is what I checked
by running bin/hadoop dfs -ls, and os.walk('home/hadoop/files')--this
is my local path in non-Hadoop environment, and even os.walk('hdfs://
host:fs_port/user/hadoop/in')....
Can anyone tell me whether I can input from file by using file
operation in mapper.py or I have to input from STDIN?
Thanks.
|
Import error when trying to access sdk datastore admin
| 4,841,024
| 2
| 1
| 769
| 0
|
python,google-app-engine
|
Use from django.utils import simplejson.
dev_appserver mimics the production environment. Nothing you install at the system level will be available for import to your scripts, to avoid imports working fine in your testing and then failing spectacularly when you deploy. However, you don't need to bundle this particular module because it's already available in the django package installed on production (and with the SDK).
In general, you do need to include external libraries in your application directory, although you can symlink them from their installed locations and they'll generally work fine (and will be deployed to production when you deploy).
| 0
| 1
| 0
| 0
|
2011-01-29T22:04:00.000
| 3
| 0.132549
| false
| 4,839,749
| 0
| 0
| 1
| 2
|
I'm getting a "ImportError: No module named simplejson" when trying to access datastore admin on the development server.
After the first time I got this error I installed the simplejson package from slackbuilds (i'm on Slackware). It seems to be working normally, I could import the simplejson module with no errors on the python console.
But the import error persists when I try to access datastore admin, even after installing the module. Restarting the development server didn't do anything.
What could be wrong?
Edit: here's the stacktrace:
Traceback (most recent call last):
File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 3245, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 3186, in _Dispatch
base_env_dict=env_dict) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 531, in Dispatch
base_env_dict=base_env_dict) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 2410, in Dispatch
self._module_dict) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 2320, in ExecuteCGI
reset_modules = exec_script(handler_path, cgi_path,
hook) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 2216, in ExecuteOrImportScript
exec module_code in script_module.dict File
"/home/lwlun/AppEngine/google_appengine/google/appengine/ext/datastore_admin/main.py",
line 30, in
from google.appengine.ext.datastore_admin
import copy_handler File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1945, in load_module
return self.FindAndLoadModule(submodule,
fullname, search_path) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1847, in FindAndLoadModule
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1798, in LoadModuleRestricted
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/datastore_admin/copy_handler.py",
line 40, in
from google.appengine.ext.datastore_admin
import utils File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1945, in load_module
return self.FindAndLoadModule(submodule,
fullname, search_path) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1847, in FindAndLoadModule
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1798, in LoadModuleRestricted
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/datastore_admin/utils.py",
line 35, in
from google.appengine.ext.mapreduce import
control File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1945, in load_module
return self.FindAndLoadModule(submodule,
fullname, search_path) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1847, in FindAndLoadModule
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1798, in LoadModuleRestricted
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/mapreduce/control.py",
line 26, in
from google.appengine.ext.mapreduce import
handlers File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1945, in load_module
return self.FindAndLoadModule(submodule,
fullname, search_path) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1847, in FindAndLoadModule
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1798, in LoadModuleRestricted
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/mapreduce/handlers.py",
line 26, in
import simplejson ImportError: No module named simplejson
|
Import error when trying to access sdk datastore admin
| 27,462,399
| 0
| 1
| 769
| 0
|
python,google-app-engine
|
If it in app engine SDK's lib, e.g on Mac it's
/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/
Copy it over to app's dir would work. It's better than pip install and then copy over, which may contain c-extension. The modules in SDK's lib path (at least simplejson) seems to have been modified to work with app engine's needs.
| 0
| 1
| 0
| 0
|
2011-01-29T22:04:00.000
| 3
| 0
| false
| 4,839,749
| 0
| 0
| 1
| 2
|
I'm getting a "ImportError: No module named simplejson" when trying to access datastore admin on the development server.
After the first time I got this error I installed the simplejson package from slackbuilds (i'm on Slackware). It seems to be working normally, I could import the simplejson module with no errors on the python console.
But the import error persists when I try to access datastore admin, even after installing the module. Restarting the development server didn't do anything.
What could be wrong?
Edit: here's the stacktrace:
Traceback (most recent call last):
File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 3245, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 3186, in _Dispatch
base_env_dict=env_dict) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 531, in Dispatch
base_env_dict=base_env_dict) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 2410, in Dispatch
self._module_dict) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 2320, in ExecuteCGI
reset_modules = exec_script(handler_path, cgi_path,
hook) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 2216, in ExecuteOrImportScript
exec module_code in script_module.dict File
"/home/lwlun/AppEngine/google_appengine/google/appengine/ext/datastore_admin/main.py",
line 30, in
from google.appengine.ext.datastore_admin
import copy_handler File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1945, in load_module
return self.FindAndLoadModule(submodule,
fullname, search_path) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1847, in FindAndLoadModule
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1798, in LoadModuleRestricted
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/datastore_admin/copy_handler.py",
line 40, in
from google.appengine.ext.datastore_admin
import utils File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1945, in load_module
return self.FindAndLoadModule(submodule,
fullname, search_path) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1847, in FindAndLoadModule
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1798, in LoadModuleRestricted
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/datastore_admin/utils.py",
line 35, in
from google.appengine.ext.mapreduce import
control File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1945, in load_module
return self.FindAndLoadModule(submodule,
fullname, search_path) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1847, in FindAndLoadModule
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1798, in LoadModuleRestricted
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/mapreduce/control.py",
line 26, in
from google.appengine.ext.mapreduce import
handlers File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1945, in load_module
return self.FindAndLoadModule(submodule,
fullname, search_path) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1847, in FindAndLoadModule
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1295, in Decorate
return func(self, *args, **kwargs) File
"/home/lwlun/AppEngine/google_appengine/google/appengine/tools/dev_appserver.py",
line 1798, in LoadModuleRestricted
description) File "/home/lwlun/AppEngine/google_appengine/google/appengine/ext/mapreduce/handlers.py",
line 26, in
import simplejson ImportError: No module named simplejson
|
setup.py and adding file to /bin/
| 9,478,011
| 15
| 81
| 48,656
| 0
|
python
|
If you're willing to build and install the entire python package, this is how I would go about it:
Edit the setup() function in setup.py to contain a parameter named scripts and set its argument as the location of the file(s) you wish to run from anywhere. e.g.
setup(name='myproject',author='',author_email='',scripts=['bin/myscript.py'])
Within the directory that contains setup.py, create a bin directory by typing mkdir bin
Add myscript.py to this newly-created bin directory (and make sure it's executable!)
cd into the directory that contains setup.py again, and install the entire python package by typing python setup.py install
Once the package is installed, you should be able to run myscript.py from anywhere on the system!
| 0
| 1
| 0
| 0
|
2011-01-29T23:41:00.000
| 4
| 1
| false
| 4,840,182
| 1
| 0
| 0
| 1
|
I can't figure out how to make setup.py add a scrip to the the user's /bin or /usr/bin or whatever.
E.g., I'd like to add a myscript.py to /usr/bin so that the user can call myscript.py from any directory.
|
DIsable Python module
| 4,842,172
| 1
| 5
| 3,339
| 0
|
python
|
As @Thomas points out, blacklisting is a pretty poor mechanism for implementing any security mechanisms. Whitelisting is a much safer approach.
But a mechanism inside the interpreter isn't particularly excellent for any number of reasons: flaws in the interpreter that are exploitable at the source code level would allow users to walk right past any mechanisms built in at that level (and the PHP team asked Linux vendors to stop calling this a security problem, because (a) they fixed one of these every week and (b) trying to confine an untrusted user-supplied script is pretty much an impossible task -- use FastCGI or similar tools for potentially untrusted scripts).
The Python interpreter is probably not designed to handle malicious input, so don't treat it as such.
If you really want to confine what untrusted users can do with Python scripts, a few pieces of advice: Do not use mod_python or anything like it. Use FastCGI or similar tools that you let specify the user account that should run the script and won't execute the script as your webserver user. And learn how to configure SELinux or AppArmor to confine what that process can do -- an hour setting up one of these tools might save you huge headaches down the road, plus you get to laugh at all the cute little exploit attempts that fail.
| 0
| 1
| 0
| 1
|
2011-01-30T09:03:00.000
| 1
| 1.2
| true
| 4,842,049
| 0
| 0
| 0
| 1
|
Is there any way to disable a module from being loaded on my system? Let's say i would like to restrict my users from accessing the subprocess or popen2 module. Something like PHP's 'disabled_functions' or any similar method to achieve the same thing.
|
bat script linking to python script
| 4,859,343
| 0
| 1
| 610
| 0
|
python,windows-xp,batch-file,hyperlink,symlink
|
When doing something similar for myself, I just created a few more batch files.
For example, you could provide a py_go.bat to invoke python theLongestPythonScriptNameInTheWorld.py
| 0
| 1
| 0
| 0
|
2011-02-01T05:37:00.000
| 3
| 0
| false
| 4,859,291
| 0
| 0
| 0
| 1
|
I have a .bat that sets up an environment which allows users to execute several python scripts for specific jobs. My goal is to create links to the scripts.
For example, the user runs the .bat, a cmd window pops up, and instead of typing python theLongestPythonScriptNameInTheWorld.py he types python go.
My target platform is windows XP, so mklink wont work here. I don't want to use fsutil hardlink. Also, I simply tried set ok=theLongestPythonScriptNameInTheWorld.py, but id rather avoid the user having to type python %go% (the modulos, since it would piss me off if i was required to type modulos). I also want to avoid WSH because I want this to run on native XP installs.
Are there any other solutions besides mklink, fsutil, set, and WSH?
|
How can you limit the allowed execution time of specific methods in the python version of Google App Engine?
| 4,862,285
| 0
| 4
| 257
| 0
|
python,google-app-engine
|
In loops, you can store the time the loop started and check how long it's been going on each iteration.
If you're not in a loop, things are a bit trickier. You could add the time-checking bit every few lines of code. This, of course, makes for really ugly code, but without the ability to spawn threads that could run a timer in the background and interrupt the running code, there's not much of a way around it.
| 0
| 1
| 0
| 0
|
2011-02-01T06:46:00.000
| 2
| 0
| false
| 4,859,734
| 0
| 0
| 1
| 1
|
Since the signal module is not supported in the python version of Google App Engine, what is the simplest way to call a method and throw/catch an exception if the method does not return in less than 2 seconds?
|
Check if the directory content has changed with shell script or python
| 4,862,410
| 1
| 6
| 4,757
| 0
|
python,shell,latex
|
Not much of a python man myself. But in a pinch, assuming you're on linux, you could periodically shell out and "ls -lrt /path/to/directory" (get the directory contents and sort by last modified), and compare the results of the last two calls for a difference. If so, then there was a change. Not very detailed, but gets the job done.
| 0
| 1
| 0
| 1
|
2011-02-01T12:08:00.000
| 7
| 0.028564
| false
| 4,862,346
| 0
| 0
| 0
| 1
|
I have a program that create files in a specific directory.
When those files are ready, I run Latex to produce a .pdf file.
So, my question is, how can I use this directory change as a trigger
to call Latex, using a shell script or a python script?
Best Regards
|
Python bluetooth transfer speed?
| 4,863,792
| -1
| 0
| 1,146
| 0
|
python,bluetooth
|
You need a binding for the Bluetooth driver/OS service that handles the Bluetooth device.
Most drivers are written in C, some in C++. If you can get the source code/API or if it's provided you might be able to access it from python. You might need to code some custom binding to your OS service to do so.
| 0
| 1
| 0
| 1
|
2011-02-01T14:27:00.000
| 3
| -0.066568
| false
| 4,863,727
| 0
| 0
| 0
| 2
|
In Python, am using the LightBlue module for Bluetooth connectivity. How do I get the speed at which I am sending file to my phone from my laptop (Ubuntu)?
|
Python bluetooth transfer speed?
| 4,870,002
| 0
| 0
| 1,146
| 0
|
python,bluetooth
|
The simplest solution is to figure out how large the file is, capture the system time before the transfer and after the transfer, and then do the math. To compute a more fine-grained transfer rate that changes over the course of the transfer, you would need to use the size of your transmit buffers and the time interval between sends.
| 0
| 1
| 0
| 1
|
2011-02-01T14:27:00.000
| 3
| 0
| false
| 4,863,727
| 0
| 0
| 0
| 2
|
In Python, am using the LightBlue module for Bluetooth connectivity. How do I get the speed at which I am sending file to my phone from my laptop (Ubuntu)?
|
Python 2.7.1 can't see Twisted
| 4,869,690
| 3
| 1
| 2,965
| 0
|
python,bash,osx-snow-leopard,twisted,.bash-profile
|
You'll need to install Twisted into your Python 2.7 installation somehow. The "2.6" in that path should be a hint that you shouldn't be trying to tell Python 2.7 about it. Among other things:
Extension modules are not compatible between python versions. You may get a segfault if you try to use them.
Bytecode formats are not compatible between python versions. Python will fall back to parsing '.py' files, which is slower.
If you're using an operating system that ships with Python 2.6, there is a good chance that the version of Twisted included is not compatible with Python 2.7, since Python 2.7 may not have been out yet when it was released.
| 0
| 1
| 0
| 0
|
2011-02-01T23:46:00.000
| 4
| 1.2
| true
| 4,869,315
| 0
| 0
| 0
| 3
|
I have a new MacBook Pro running OS X 10.6.6 / Snow Leopard -- which ships with Python 2.6, although I have installed 2.7.1
Unfortunately, this doesn't seem to see the Twisted install in the 2.6/Extras/lib/python/twisted directory, as I find I'm unable to import modules that I can see are present in that directory.
"which python" returns "/Library/Frameworks/Python.framework/Versions/2.7/bin/python"
and running python returns the same: "Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)"
I have added the twisted directory (absolute) to sys.path, and I have added it to .bash_profile, which now consists of the following:
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
PATH=$PATH:/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted
export PATH
Any ideas how I can get 2.7.1 to see the Twisted install? Or am I trying to do something that just can't be done?
thanks.
|
Python 2.7.1 can't see Twisted
| 4,869,359
| 2
| 1
| 2,965
| 0
|
python,bash,osx-snow-leopard,twisted,.bash-profile
|
Create an environment using virtualenv.
Install Twisted in your newly created environment using pip.
| 0
| 1
| 0
| 0
|
2011-02-01T23:46:00.000
| 4
| 0.099668
| false
| 4,869,315
| 0
| 0
| 0
| 3
|
I have a new MacBook Pro running OS X 10.6.6 / Snow Leopard -- which ships with Python 2.6, although I have installed 2.7.1
Unfortunately, this doesn't seem to see the Twisted install in the 2.6/Extras/lib/python/twisted directory, as I find I'm unable to import modules that I can see are present in that directory.
"which python" returns "/Library/Frameworks/Python.framework/Versions/2.7/bin/python"
and running python returns the same: "Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)"
I have added the twisted directory (absolute) to sys.path, and I have added it to .bash_profile, which now consists of the following:
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
PATH=$PATH:/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted
export PATH
Any ideas how I can get 2.7.1 to see the Twisted install? Or am I trying to do something that just can't be done?
thanks.
|
Python 2.7.1 can't see Twisted
| 4,869,332
| 3
| 1
| 2,965
| 0
|
python,bash,osx-snow-leopard,twisted,.bash-profile
|
You'll have to install twisted using python 2.7.
Also, python doesn't look up what's in the PATH variable for imports, it looks in PYTHONPATH. But just putting your python 2.6 folder in your pythonpath isn't a very good solution.
| 0
| 1
| 0
| 0
|
2011-02-01T23:46:00.000
| 4
| 0.148885
| false
| 4,869,315
| 0
| 0
| 0
| 3
|
I have a new MacBook Pro running OS X 10.6.6 / Snow Leopard -- which ships with Python 2.6, although I have installed 2.7.1
Unfortunately, this doesn't seem to see the Twisted install in the 2.6/Extras/lib/python/twisted directory, as I find I'm unable to import modules that I can see are present in that directory.
"which python" returns "/Library/Frameworks/Python.framework/Versions/2.7/bin/python"
and running python returns the same: "Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)"
I have added the twisted directory (absolute) to sys.path, and I have added it to .bash_profile, which now consists of the following:
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
PATH=$PATH:/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted
export PATH
Any ideas how I can get 2.7.1 to see the Twisted install? Or am I trying to do something that just can't be done?
thanks.
|
Memcache not present in App-Engine-Patch?
| 4,870,311
| 1
| 1
| 1,200
| 0
|
google-app-engine,memcached,app-engine-patch,python-memcached
|
It looks like you're attempting to make a memcache call at import time. Judging from the stacktrace, Django imports your modules before it sets up the App Engine environment, and therefore any calls to App Engine services at the module level will fail on the development server.
Move the call to memcache inside a function that's called from a request handler, and it should resolve your problem.
| 0
| 1
| 0
| 0
|
2011-02-02T02:03:00.000
| 1
| 1.2
| true
| 4,870,102
| 0
| 0
| 1
| 1
|
I'm trying to store a date into memcache using the following code:
from datetime import date
from google.appengine.api.memcache import Client
MEMCACHE_DATE_KEY = 'date'
client = Client()
def last_date():
return client.get(MEMCACHE_DATE_KEY)
def new_date():
client.set(MEMCACHE_DATE_KEY, date.today())
I am getting this error:
Traceback (most recent call last):
File "manage.py", line 4, in
setup_env(manage_py_env=True)
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/aecmd.py", line 67, in setup_env
patch_all()
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/appenginepatcher/patch.py", line 29, in patch_all
patch_app_engine()
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/appenginepatcher/patch.py", line 520, in patch_app_engine
db.Model._meta = _meta(db.Model, ())
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/appenginepatcher/patch.py", line 258, in __init__
settings.INSTALLED_APPS
File "/Users/benji/Projects/share-renting-engine/common/zip-packages/django-1.1.zip/django/utils/functional.py", line 269, in __getattr__
File "/Users/benji/Projects/share-renting-engine/common/zip-packages/django-1.1.zip/django/conf/__init__.py", line 40, in _setup
File "/Users/benji/Projects/share-renting-engine/common/zip-packages/django-1.1.zip/django/conf/__init__.py", line 73, in __init__
File "/Users/benji/Projects/share-renting-engine/common/zip-packages/django-1.1.zip/django/utils/importlib.py", line 35, in import_module
File "/Users/benji/Projects/share-renting-engine/settings.py", line 120, in
from ragendja.settings_post import *
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/ragendja/settings_post.py", line 98, in
check_app_imports(app)
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/ragendja/settings_post.py", line 63, in check_app_imports
__import__(app, {}, {}, [''])
File "/Users/benji/Projects/share-renting-engine/engine/__init__.py", line 5, in
if date.today() != last_date():
File "/Users/benji/Projects/share-renting-engine/engine/utils/date.py", line 12, in last_date
return client.get(MEMCACHE_DATE_KEY)
File "/Users/benji/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py", line 428, in get
self._make_sync_call('memcache', 'Get', request, response)
File "/Users/benji/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 86, in MakeSyncCall
return stubmap.MakeSyncCall(service, call, request, response)
File "/Users/benji/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 279, in MakeSyncCall
assert stub, 'No api proxy found for service "%s"' % service
AssertionError: No api proxy found for service "memcache"
How can i use memcache with app-engine-patch?
Thanks for your time.
|
Considerations for moving our web app to an appliance
| 4,872,968
| 0
| 3
| 124
| 0
|
python,appliance
|
It depends on what langauge/tecnology application is written.
If it is java, release war file + tomcat/jboss.
If it is python, release eggs.
If it is php... not sure, probably just .tar.bz2.
Linux distro or virtual image mught be advantage, but I dislike using them, because they are usually does not fits to my infra (why do I have to install some custom debian-based distro to my rhel-only infrastructure?).
| 0
| 1
| 0
| 1
|
2011-02-02T09:33:00.000
| 2
| 0
| false
| 4,872,722
| 0
| 0
| 1
| 1
|
We have developed a web application running on Linux that is quite popular. We now wish to release it as an appliance so customers can run it internally on their own networks.
We are unsure of the best approach. We are flexible on areas such as: the Linux distro, whether it's a hardware or software only appliance. Does anyone have any advice on the best way to go about this? Links to any good resources on the subject? Questions we should be asking ourselves? Legal considerations for a commercial app? Security considerations?
UPDATE:
It's a Python based web application. We would like the user to be able to do everything via a web interface. No command line stuff etc.
|
Where is the most authoritative/complete source of documentation on rpm-python module?
| 4,935,001
| 0
| 1
| 658
| 0
|
python,rpm,rhel5
|
If you are on RHEL then you could seriously consider using the yum APIs instead of rpm-python directly ... the API is much easier to use.
| 0
| 1
| 0
| 1
|
2011-02-02T22:45:00.000
| 3
| 0
| false
| 4,880,818
| 1
| 0
| 0
| 1
|
Trying to learn how to use the rpm-python module (i.e. "import rpm" on RHEL5). I can't find any tutorials that are complete or recent. Specifically regarding how to install and manage rpm's on a system. Anyone?
|
How can I add python to cmd in windows
| 19,559,108
| 15
| 13
| 46,626
| 0
|
python,windows,python-3.x
|
Right click on my computer>got to properties>advanced settings>environmental variables>
choose path and add the installed python dirtory to that path as like below:
C:\WINDOWS\system32;C:\WINDOWS;C:\Python27
| 0
| 1
| 0
| 0
|
2011-02-03T05:27:00.000
| 2
| 1
| false
| 4,882,808
| 1
| 0
| 0
| 1
|
I have python 3.1 installed, and I have added it to the system path too. Now I can open "cmd" and type python to start python, but whenever I try to open cmd in a specific directory by using (shift + right click -> open command prompt here), and type python, it says "command not found"!
How can I fix this?
|
access denied in python
| 4,883,551
| 1
| 1
| 757
| 0
|
python
|
you have to start the process as root. You can run "sudo yourscript.py" as your normal user account or log in as root or run "su -" to become root and then run your script.
Your script cannot obtain root privileges after it starts running. That's just not how unix/linux systems work.
| 0
| 1
| 0
| 0
|
2011-02-03T07:41:00.000
| 2
| 0.099668
| false
| 4,883,541
| 0
| 0
| 0
| 1
|
hi everybody
i wanna take a dir from one directory and os doesn't allow me to do this work(for example /etc/openvpn in linux) and i know i should be root but i don't know how can i do this with python.
|
Can I catch error codes when using Fabric to run() calls in a remote shell?
| 4,888,891
| 4
| 70
| 44,680
| 0
|
python,error-handling,fabric
|
Apparently messing with the environment is the answer.
fabric.api.settings can be used as a context manager (with with) to apply it to individual statements. The return value of run(), local() and sudo() calls isn't just the output of the shell command, but also has special properties (return_code and failed) that allow reacting to the errors.
I guess I was looking for something closer to the behaviour of subprocess.Popen or Python's usual exception handling.
| 0
| 1
| 0
| 1
|
2011-02-03T16:11:00.000
| 4
| 0.197375
| false
| 4,888,568
| 0
| 0
| 0
| 1
|
Normally Fabric quits as soon as a run() call returns a non-zero exit code. For some calls, however, this is expected. For example, PNGOut returns an error code of 2 when it is unable to compress a file.
Currently I can only circumvent this limitation by either using shell logic (do_something_that_fails || true or do_something_that_fails || do_something_else), but I'd rather be able to keep my logic in plain Python (as is the Fabric promise).
Is there a way to check for an error code and react to it rather than having Fabric panic and die? I still want the default behaviours for other calls, so changing its behaviour by modifying the environment doesn't seem like a good option (and as far as I recall, you can only use that to tell it to warn instead of dying anyway).
|
Python script - connect to SSH and run command
| 39,664,919
| 1
| 10
| 74,237
| 0
|
python,automation,ssh,telnet
|
There are many libraries to do that.
Subprocess
Pexpect
Paramiko (Mostly used)
Fabric
Exscript
You can check their documentation for the implementation.
| 0
| 1
| 1
| 1
|
2011-02-04T10:12:00.000
| 7
| 0.028564
| false
| 4,896,785
| 0
| 0
| 0
| 1
|
I already know there are ssh modules for Python, that's not for what I'm looking for.
What I want to have is an python script to do the following:
> connect to an [ input by user ] SSH host
> connect using the credentials [ provided by the user ]
> run command on the SSH host [ telnet to [host - input by user ]
> Select menu item in the telnet session
Thanks in advance,
Best regards,
|
highlighting a window in GNOME's window list
| 4,906,739
| 1
| 1
| 495
| 0
|
python,perl,gtk
|
I'm not really into GTK programming, but as far as i know you want to set an "URGENT"-Flag for the Window which should be highlighted. Maybe this will get you any further. :)
| 1
| 1
| 0
| 0
|
2011-02-05T10:51:00.000
| 2
| 0.099668
| false
| 4,906,424
| 0
| 0
| 0
| 1
|
In order to indicate activity, some applications (e.g. Pidgin) highlight their entry in GNOME's Window List panel widget (e.g. via bold font or flashing color). This indication is reset automatically when the window is activated.
I have a terminal application for which I would like to achieve the same thing (preferably via Perl, but Python would work too) - but I have no idea where to start. I imagine I'd first have to find the terminal window (based on window title) and then trigger some kind of GTK action.
Any help would be greatly appreciated!
|
Windows Gstreamer ALSA Alternative?
| 4,925,220
| 0
| 2
| 2,273
| 0
|
python,windows,gstreamer,alsa
|
9000's answer, sdl, and autoaudiosrc/sink are the answer :)
| 0
| 1
| 0
| 0
|
2011-02-05T15:49:00.000
| 4
| 0
| false
| 4,907,828
| 0
| 0
| 0
| 3
|
Does anyone know an alternative to ALSA that can be used on windows, with gstreamer, and how to install it, and where to find python bindings for it if it needs it?
thanks xxx
|
Windows Gstreamer ALSA Alternative?
| 4,907,925
| 0
| 2
| 2,273
| 0
|
python,windows,gstreamer,alsa
|
It seems that on Windows the SDK installer doesn't actually install the bindings to any location visible to the Python interpreter. You can find the files at sdk\bindings\python\v2.6\lib\site-packages. Copy the contents of the directory to your Python installation's site-packages, and you should be able to import the library.
| 0
| 1
| 0
| 0
|
2011-02-05T15:49:00.000
| 4
| 0
| false
| 4,907,828
| 0
| 0
| 0
| 3
|
Does anyone know an alternative to ALSA that can be used on windows, with gstreamer, and how to install it, and where to find python bindings for it if it needs it?
thanks xxx
|
Windows Gstreamer ALSA Alternative?
| 5,058,755
| 3
| 2
| 2,273
| 0
|
python,windows,gstreamer,alsa
|
SDL does a decent job of abstracting sound interfaces in a platform-independent way. PyGame contains an interface to SDL and works on many platforms. Such abstraction, of course, sets many limitations, but maybe it will still do for you.
Converted from a comment.
| 0
| 1
| 0
| 0
|
2011-02-05T15:49:00.000
| 4
| 1.2
| true
| 4,907,828
| 0
| 0
| 0
| 3
|
Does anyone know an alternative to ALSA that can be used on windows, with gstreamer, and how to install it, and where to find python bindings for it if it needs it?
thanks xxx
|
Apache Config - Multiple python versions
| 29,809,235
| 2
| 2
| 2,129
| 0
|
python,apache
|
To use with Python 3, you need to install the right mod_wsgi for python 3.
On Debian or Ubuntu : sudo apt-get install libapache2-mod-wsgi-py3.
For older versions of Python, when installing mod_wsgi, type : ./configure --with-python=/usr/local/bin/python2.5 for version 2.5 for instance.
| 0
| 1
| 0
| 1
|
2011-02-07T22:59:00.000
| 3
| 0.132549
| false
| 4,927,688
| 1
| 0
| 0
| 3
|
I have a couple versions of python on my box. My app uses python 2.7 which is found in /usr/local/bin/python. Apache seems to be using an earlier version in /usr/bin/python. How can I configure Apache to use a later version of Python for my app?
|
Apache Config - Multiple python versions
| 4,928,096
| 0
| 2
| 2,129
| 0
|
python,apache
|
I could be mistaking, but whatever user apache is started with has a profile which likely has the search path in it. You could change the search path to search /usr/local/bin before /usr/bin, though this is not an ideal approach. Whatever default shell is set for the account used by Apache, just check that you have an rc-file for that shell, and if not, create one.
| 0
| 1
| 0
| 1
|
2011-02-07T22:59:00.000
| 3
| 0
| false
| 4,927,688
| 1
| 0
| 0
| 3
|
I have a couple versions of python on my box. My app uses python 2.7 which is found in /usr/local/bin/python. Apache seems to be using an earlier version in /usr/bin/python. How can I configure Apache to use a later version of Python for my app?
|
Apache Config - Multiple python versions
| 4,927,767
| 1
| 2
| 2,129
| 0
|
python,apache
|
You can't. Either rebuild mod_wsgi against the other version of Python, or change the shebang line in your CGI scripts to the other executable.
| 0
| 1
| 0
| 1
|
2011-02-07T22:59:00.000
| 3
| 1.2
| true
| 4,927,688
| 1
| 0
| 0
| 3
|
I have a couple versions of python on my box. My app uses python 2.7 which is found in /usr/local/bin/python. Apache seems to be using an earlier version in /usr/bin/python. How can I configure Apache to use a later version of Python for my app?
|
How to install easy_install in Python 2.7.1 on Windows 7
| 28,389,353
| 0
| 30
| 125,598
| 0
|
python,easy-install
|
I know this isn't a direct answer to your question but it does offer one solution to your problem. Python 2.7.9 includes PIP and SetupTools, if you update to this version you will have one solution to your problem.
| 0
| 1
| 0
| 0
|
2011-02-08T06:29:00.000
| 7
| 0
| false
| 4,930,216
| 1
| 0
| 0
| 1
|
I have installed Python 2.7.1 on Windows 7, but I am unable to install easy_install.
Please help me.
|
Change Bluetooth name Python
| 4,931,264
| 1
| 0
| 1,096
| 0
|
python,bluetooth,ubuntu-10.10
|
Invoke org.bluez.Adapter.SetProperty(u'Name', u'New name here') in the /org/bluez/<pid>/<device> object path on the org.bluez D-Bus bus.
| 0
| 1
| 0
| 1
|
2011-02-08T09:10:00.000
| 1
| 1.2
| true
| 4,931,244
| 0
| 0
| 0
| 1
|
I'm using PyBluez on Ubuntu 10.10. I would like to know how is possible to change the bluetooth name of the local device in software. I couldn't find any command related..
|
How to periodically create an HTTP POST request from windows
| 4,955,373
| 1
| 1
| 2,416
| 0
|
python,http,windows-services,scheduled-tasks
|
This is trivially easy with a scheduled task which is the native Windows way to schedule tasks! There's no need for cygwin or Python or anything like that.
I have such a task running on my machine which pokes my Wordpress blog every few hours. The script is just a .bat file which calls wget. The task is configured to "Run whether user is logged on or not" which ensures that it runs when I'm not logged on. There's no "black cmd window".
You didn't say which version of Windows you are on and if you are on XP (unlucky for you if you are) then the configuration is probably different since the scheduled task interface changed quite a bit when Vista came out.
| 0
| 1
| 1
| 0
|
2011-02-08T15:56:00.000
| 3
| 0.066568
| false
| 4,935,257
| 0
| 0
| 0
| 2
|
I need to install on one of my Windows PC's some software that will periodically send a short HTTP POST request to my remote development server. The request is always the same and should get sent every minute.
What would you recommend as the best approach for that?
The things I considered are:
1. Creating a Windows service
2. Using a script in python (I have cygwin installed)
3. Scheduled task using a batch file (although I don't want the black cmd window to pop up in my face every minute)
Thanks for any additional ideas or hints on how to best implement it.
|
How to periodically create an HTTP POST request from windows
| 4,935,443
| 2
| 1
| 2,416
| 0
|
python,http,windows-services,scheduled-tasks
|
If you have cygwin, you probably have cron - run a python script from your crontab.
| 0
| 1
| 1
| 0
|
2011-02-08T15:56:00.000
| 3
| 0.132549
| false
| 4,935,257
| 0
| 0
| 0
| 2
|
I need to install on one of my Windows PC's some software that will periodically send a short HTTP POST request to my remote development server. The request is always the same and should get sent every minute.
What would you recommend as the best approach for that?
The things I considered are:
1. Creating a Windows service
2. Using a script in python (I have cygwin installed)
3. Scheduled task using a batch file (although I don't want the black cmd window to pop up in my face every minute)
Thanks for any additional ideas or hints on how to best implement it.
|
Detecting Type of Video Stream
| 4,935,406
| 1
| 0
| 281
| 0
|
python,bash,streaming,video-streaming,multimedia
|
what about trying pyffmpeg out. you should be able to get the container info from that.
| 0
| 1
| 0
| 0
|
2011-02-08T16:08:00.000
| 1
| 1.2
| true
| 4,935,387
| 0
| 0
| 0
| 1
|
I have 2 video streams
(1) VLC Generated Compressed MP4 UDP stream
(2) DV Uncompressed UDP Stream
Both are destined to a host. At this Unix receiving host, I would like to detect type of stream coming using Bash or Python Scripting (without tcpdump, I do not have root priv.)
ANY idea guys how to implement ?
Thank you.
|
Is it possible to deploy a Python application on the Mac App Store?
| 4,971,779
| 1
| 49
| 14,346
| 0
|
python,macos,app-store,py2app
|
Apple provides the Build Applet tool for Python with Xcode so it should be supported by the App store. MacOS X 10.6.6 includes Python 2.5 and 2.6 as part of the default install, you can specify /usr/bin/python2.5 and /usr/lib/python2.5.
| 0
| 1
| 0
| 0
|
2011-02-09T00:45:00.000
| 6
| 0.033321
| false
| 4,940,273
| 1
| 0
| 0
| 2
|
Does Apple accept Python applications for distribution on the new Mac App Store?
If so, how should the application be packaged? Is py2app sufficient? Something else?
|
Is it possible to deploy a Python application on the Mac App Store?
| 4,993,464
| 9
| 49
| 14,346
| 0
|
python,macos,app-store,py2app
|
I know it's possible because I know of at least one Python-based app that is in the app store ("Pennywise", which is based on my own app, moneyGuru, which uses Python + PyObjc + py2app). I didn't do it myself, so I'm not sure of the details.
| 0
| 1
| 0
| 0
|
2011-02-09T00:45:00.000
| 6
| 1
| false
| 4,940,273
| 1
| 0
| 0
| 2
|
Does Apple accept Python applications for distribution on the new Mac App Store?
If so, how should the application be packaged? Is py2app sufficient? Something else?
|
How to run programs in python2 and python3
| 4,940,647
| 0
| 9
| 44,324
| 0
|
python
|
The shell will read the PATH from left to right, so you most likely defined Python 3.1.3 before Python 2.6.6. Specify the full path for each to use both versions.
| 0
| 1
| 0
| 0
|
2011-02-09T02:02:00.000
| 6
| 0
| false
| 4,940,617
| 1
| 0
| 0
| 3
|
I have python 2.6.6 and python 3.1.3 currently installed on my machine (Windows Vista 64 bit)
My path variable includes the directory of both versions. How can I specify which python I want to run a program in. For instance, if I want to run a program in python 3, it works but if I want to run a different program in python2 I get a syntax error. So how can I run a python 2 program in the cmd?
Typing python in my command line, python 3.1.3 is the only one that shows up.
|
How to run programs in python2 and python3
| 4,940,652
| 8
| 9
| 44,324
| 0
|
python
|
You can specify the version in the executable name python2.6 and python3.
| 0
| 1
| 0
| 0
|
2011-02-09T02:02:00.000
| 6
| 1.2
| true
| 4,940,617
| 1
| 0
| 0
| 3
|
I have python 2.6.6 and python 3.1.3 currently installed on my machine (Windows Vista 64 bit)
My path variable includes the directory of both versions. How can I specify which python I want to run a program in. For instance, if I want to run a program in python 3, it works but if I want to run a different program in python2 I get a syntax error. So how can I run a python 2 program in the cmd?
Typing python in my command line, python 3.1.3 is the only one that shows up.
|
How to run programs in python2 and python3
| 4,940,631
| 6
| 9
| 44,324
| 0
|
python
|
Instead of just typing "python" on the command line, use the full path the python.exe that you want to run: FULL_PATH_TO_PYTHON_2.6.6\python.exe or FULL_PATH_TO_PYTHON_3.1.3\python.exe should distinguish between the two.
| 0
| 1
| 0
| 0
|
2011-02-09T02:02:00.000
| 6
| 1
| false
| 4,940,617
| 1
| 0
| 0
| 3
|
I have python 2.6.6 and python 3.1.3 currently installed on my machine (Windows Vista 64 bit)
My path variable includes the directory of both versions. How can I specify which python I want to run a program in. For instance, if I want to run a program in python 3, it works but if I want to run a different program in python2 I get a syntax error. So how can I run a python 2 program in the cmd?
Typing python in my command line, python 3.1.3 is the only one that shows up.
|
Removing duplicated lines from a txt file
| 4,948,705
| 1
| 5
| 7,337
| 0
|
python,linux,awk
|
Since you need the extra bits the fastest way is to create a set of unique entries (sort -u will do) and then you must compare each entry against each other, e.g.
if x.startswith(y) and not y.startswith(x)
and just leave x and discard y.
| 0
| 1
| 0
| 0
|
2011-02-09T17:46:00.000
| 8
| 0.024995
| false
| 4,948,509
| 1
| 0
| 0
| 1
|
I am processing large text files (~20MB) containing data delimited by line.
Most data entries are duplicated and I want to remove these duplications to only keep one copy.
Also, to make the problem slightly more complicated, some entries are repeated with an extra bit of info appended. In this case I need to keep the entry containing the extra info and delete the older versions.
e.g.
I need to go from this:
BOB 123 1DB
JIM 456 3DB AX
DAVE 789 1DB
BOB 123 1DB
JIM 456 3DB AX
DAVE 789 1DB
BOB 123 1DB EXTRA BITS
to this:
JIM 456 3DB AX
DAVE 789 1DB
BOB 123 1DB EXTRA BITS
NB. the final order doesn't matter.
What is an efficient way to do this?
I can use awk, python or any standard linux command line tool.
Thanks.
|
FTP filename encoding
| 5,210,013
| 2
| 1
| 3,170
| 0
|
python,encoding,ftp,twisted
|
FTP ignores encodings; as long as a filename does not contain a '\0' (null character) and '/' (slash) separates directories, it happily accepts anything.
Do your own decoding and encoding of the filenames. It is quite probable that the encoding used in your example is "cp1252", which is the “Windows Western” or something like that.
In your case, when you receive 'Illusion-N\xf3z.txt', convert it to Unicode by 'Illusion-N\xf3z.txt'.decode('cp1252').
| 0
| 1
| 0
| 1
|
2011-02-11T08:12:00.000
| 2
| 0.197375
| false
| 4,966,856
| 0
| 0
| 0
| 1
|
Hi
I use twisted library to connect to FTP server but I have problem with filename encoding.
I receive 'Illusion-N\xf3z.txt' so its not unicode. Is there any FTP command to force specific encoding?
Thanks in advance!
MK
|
Lexing and Parsing Utilities
| 4,992,038
| 1
| 5
| 1,406
| 0
|
python,ruby,parsing,lexical-analysis,guile
|
NL text tends have to lots of ambiguity. If you want to parse natural langauge, I don't think any of the classic compiler-type parser generators (LALR, LL [including ANTLR]) will help you much, and compiler type parser generators typically don't handle this at all.
A GLR parser, which does handle ambiguity, may be of some use; bison offers this as an option.
| 0
| 1
| 0
| 0
|
2011-02-13T04:39:00.000
| 3
| 0.066568
| false
| 4,982,455
| 0
| 0
| 0
| 1
|
I'm looking for lexical analysis and parser-generating utilities that are not Flex or Bison. Requirements:
Parser is specified using a context-free LL(*) or GLR grammar. I would also consider PEGs.
Integrates tightly with a programming language that could be used for both scripting and application development. Language should also have facilities for easily interfacing with C. Good examples are Python, Ruby, and Guile. No C, Java, or Perl please. I want the language to be homogeneous; I want the parser generator to output code in the same language.
Well-documented and production-quality.
Open source. Free is also desirable (although not required).
Compatible with Linux distributions or one of the open source BSDs. I would consider OpenSolaris.
Rapid development is a considerably greater concern than efficiency.
Suited to parsing natural language as well as formal languages. Natural language parsing is limited to short, simple sentences with very little ambiguity.
I have my eye on ANTLR, although I have never used it. Comments to that effect are appreciated. Let me know what your favorite utilities are that meet these requirements, and why you would recommend them.
|
Python interpreter path search order on windows
| 4,984,297
| 0
| 0
| 453
| 0
|
python,path,interpreter
|
If you are having problems with PATH in windows, set the one you want to use at the start of the path variable. Plus, you might want to use User variables instead of system ones.
But I don't know if that answers your question because you didn't really ask anything.
| 0
| 1
| 0
| 1
|
2011-02-13T12:27:00.000
| 2
| 0
| false
| 4,984,124
| 1
| 0
| 0
| 1
|
Many applications include a python interpreter, so now when I try to run a program, Subversion's 2.5 interpreter is used to execute it.
I've already changed environment path order, putting subversion's last.
Now when I run python from command line, the 2.7 is run, but when I pass the script's filename, version 2.5 seems to be running it, as a few exceptions reveal the path.
So specifically, python 2.7 tries to imports module from subversions path.
|
Merge and sync stdout and stderr?
| 4,984,598
| 1
| 5
| 3,540
| 0
|
python,subprocess,stdout,stderr
|
You can merge them passing subprocess.STDOUT as the stderr argument for subprocess.Popen, but I don't know if they will be formatted with time and source.
| 0
| 1
| 0
| 0
|
2011-02-13T14:02:00.000
| 2
| 0.099668
| false
| 4,984,549
| 1
| 0
| 0
| 1
|
say I'm running an exe from a python script using:
subprocess.call(cmdArgs,stdout=outf, stderr=errf)
when outf and errf are file descriptors of text files.
is there any way I can generate on top of it a merged and synced text file of both stdout and stderr?
it should be formatted with time and source(our/err).
thanks
|
Using pickle for in-memory "transaction"?
| 4,986,678
| 1
| 1
| 310
| 0
|
python,transactions,pickle,undo
|
Well, as you mentioned the data design is loosely coupled, so you I don't think you need to pickle it if it's in memory. Just take a copy of all the relevant variables, and the transaction.abort() would just copy them back, and transaction.commit() would then just remove the copy of the data.
There are issues, but none that you don't have with the pickle solution.
| 0
| 1
| 0
| 0
|
2011-02-13T19:50:00.000
| 2
| 1.2
| true
| 4,986,467
| 1
| 0
| 0
| 2
|
A user can perform an action, which may trigger dependent actions (which themselves may have dependent actions) and I want to be able to cancel the whole thing if the user cancels a dependent action.
The typical way I've seen this done is some variant of an undo stack and each action will need to know how to undo itself, and then if a child action is cancelled the undo's cascade their way up. Sometimes writing undo methods are tricky and there isn't always enough information in context to properly know how to undo an action in an isolated manner.
I just thought of a (potentially) easier way which is to just pickle the state of the (relevant parts of) program, and then the cancel would just restore to it's former state, without needing to create separate undo logic for each action.
Has anyone tried this? Any gotchas to watch out for? Any reason not to do this?
Edit: The dependent actions must happen after the parent action (and even whether there are dependent actions may depend on the result of the parent action), so just checking all the dependencies before doing anything isn't an option. I guess you could say an action triggers other actions, but if one of the triggered actions cannot be performed, then none of it happened.
|
Using pickle for in-memory "transaction"?
| 4,986,707
| 1
| 1
| 310
| 0
|
python,transactions,pickle,undo
|
You can use pickle to store your state if all elements of state are serializable (usually they are). The only reasons for not doing so:
if you have to store pointers to any objects that are not saved in state, you will have problems with these pointers after performing undo operation.
this method could be expensive, depending on the size of your state.
Also you can use zip() to lower memory usage in exchange of raising CPU usage.
| 0
| 1
| 0
| 0
|
2011-02-13T19:50:00.000
| 2
| 0.099668
| false
| 4,986,467
| 1
| 0
| 0
| 2
|
A user can perform an action, which may trigger dependent actions (which themselves may have dependent actions) and I want to be able to cancel the whole thing if the user cancels a dependent action.
The typical way I've seen this done is some variant of an undo stack and each action will need to know how to undo itself, and then if a child action is cancelled the undo's cascade their way up. Sometimes writing undo methods are tricky and there isn't always enough information in context to properly know how to undo an action in an isolated manner.
I just thought of a (potentially) easier way which is to just pickle the state of the (relevant parts of) program, and then the cancel would just restore to it's former state, without needing to create separate undo logic for each action.
Has anyone tried this? Any gotchas to watch out for? Any reason not to do this?
Edit: The dependent actions must happen after the parent action (and even whether there are dependent actions may depend on the result of the parent action), so just checking all the dependencies before doing anything isn't an option. I guess you could say an action triggers other actions, but if one of the triggered actions cannot be performed, then none of it happened.
|
Step by step setting up python with pip and virtualenv?
| 4,987,311
| 2
| 4
| 3,496
| 0
|
python
|
What problems?
Install PIP: easy-install pip
Install virtualenv: pip install virtualenv
Create a virtualenv environment: virtualenv myenv
Enter to environment: source myenv/bin/activate or use myenv/bin/python
???
PROFIT!
| 0
| 1
| 0
| 0
|
2011-02-13T21:11:00.000
| 2
| 0.197375
| false
| 4,986,896
| 1
| 0
| 0
| 1
|
Are there any good step by step tutorials on setting up a Mac to use python, pip and virtualenv setup?
|
Modules between multiple versions of Python Linux
| 4,991,407
| 3
| 4
| 2,117
| 0
|
python
|
Don't attempt to share them; this has some chance of success with pure Python modules, but C modules will fail to work. Instead, install them using the appropriate interpreter executable, e.g. python2.4 setup.py install.
| 0
| 1
| 0
| 0
|
2011-02-14T11:02:00.000
| 2
| 0.291313
| false
| 4,991,366
| 1
| 0
| 0
| 1
|
I have Python2.6.5 and Python2.4.4 on my linux machine.
At the moment, all the modules I have (wx, ply, pyserial, twisted, to name a few) are installed for the 2.6 version of python. If I try to import wx on Python2.4, I get the expected no module error.
The problem here, is that I have a lot of devices (Let's say over a thousand) all running 2.4.4, which will soon need to be supported by this machine (For builds of code, releases etc). Until now, I've been using an EeePC (Same device as the ones I'm supporting) to do builds and releases, which has worked well. (I develop on the 2.6 machine, and build on the EeePC).
How would I go about getting these modules to work for Python2.4? I've tried reinstalling (With 2.4 as my primary), but that just caused errors. The blogs/answers I've found say to use easy_install, but that doesn't support the packages I need (Or at least, it just died when I tried).
In short: I'm currently using python 2,6, but I'd like it to change to 2.4 for all the modules as that's what I'm going to be using.
|
running several system commands in parallel in Python
| 4,992,558
| 2
| 33
| 45,031
| 0
|
python
|
If your running system commands you can just create the process instances with the subprocess module, call them as you want. There shouldn't be any need to thread (its unpythonic) and multiprocess seems a tad overkill for this task.
| 0
| 1
| 0
| 0
|
2011-02-14T12:59:00.000
| 7
| 0.057081
| false
| 4,992,400
| 1
| 0
| 0
| 1
|
I write a simple script that executes a system command on a sequence of files.
To speed things up, I'd like to run them in parallel, but not all at once - i need to control maximum number of simultaneously running commands.
What whould be the easiest way to approach this ?
|
Is there no way to serve a static directory and its children i Cherrypy?
| 4,994,618
| 1
| 0
| 357
| 0
|
python,cherrypy
|
Not sure in CherryPY, but why not configure your front end webserver to serve static files? You really don't want that traffic hitting your framework.
| 0
| 1
| 0
| 0
|
2011-02-14T16:20:00.000
| 2
| 0.099668
| false
| 4,994,493
| 1
| 0
| 0
| 2
|
Using Cherrypy version 3.0.2
Given a file-structure like this:
static-dir
2011
2010
2009
...
I use the configuration: '/static': {'tools.staticdir.on': True, 'tools.staticdir.dir': 'static-dir'}
This works fine fore getting /static/anyfile
But if I try /static/2009/anyfile I get an error. I can add an entry in the configuration for this directory like:
'/static/2009': {'tools.staticdir.on': True, 'tools.staticdir.dir': 'static-dir/2009'}
This works, but it there no other way to serve sub-directory’s? Do I have to enter every directory under static-dir in then configuration to serve them?
|
Is there no way to serve a static directory and its children i Cherrypy?
| 4,997,347
| 1
| 0
| 357
| 0
|
python,cherrypy
|
You shouldn't have to enter multiple entries; it should descend as far down as you need to. What error are you getting? 404? If you're using Cherrypy 3.2, try setting 'tools.staticdir.debug' to True.
| 0
| 1
| 0
| 0
|
2011-02-14T16:20:00.000
| 2
| 1.2
| true
| 4,994,493
| 1
| 0
| 0
| 2
|
Using Cherrypy version 3.0.2
Given a file-structure like this:
static-dir
2011
2010
2009
...
I use the configuration: '/static': {'tools.staticdir.on': True, 'tools.staticdir.dir': 'static-dir'}
This works fine fore getting /static/anyfile
But if I try /static/2009/anyfile I get an error. I can add an entry in the configuration for this directory like:
'/static/2009': {'tools.staticdir.on': True, 'tools.staticdir.dir': 'static-dir/2009'}
This works, but it there no other way to serve sub-directory’s? Do I have to enter every directory under static-dir in then configuration to serve them?
|
How to create a spinning command line cursor?
| 4,995,772
| 3
| 85
| 76,617
| 0
|
python,command-line-interface,progress
|
Sure, it's possible. It's just a question of printing the backspace character (\b) in between the four characters that would make the "cursor" look like it's spinning ( -, \, |, /).
| 0
| 1
| 0
| 0
|
2011-02-14T18:17:00.000
| 23
| 0.026081
| false
| 4,995,733
| 1
| 0
| 0
| 1
|
Is there a way to print a spinning cursor in a terminal using Python?
|
How to just call a command and not get its output
| 4,996,861
| 3
| 40
| 60,925
| 0
|
python,subprocess
|
just call it as you are and tack >/dev/null on the end of the comamnd. That will redirect any textual output.
| 0
| 1
| 0
| 0
|
2011-02-14T20:22:00.000
| 4
| 0.148885
| false
| 4,996,852
| 0
| 0
| 0
| 2
|
In Python, what is the shortest and the standard way of calling a command through subprocess but not bothering with its output.
I tried subprocess.call however it seems to return the output. I am not bothered with that, I just need to run the program silently without the output cluttering up the screen.
If it helps, I am callling pdflatex and my intention is just to call it.
|
How to just call a command and not get its output
| 20,773,568
| 3
| 40
| 60,925
| 0
|
python,subprocess
|
Use the /dev/null if you are using Unix. If you run any command in Shell and don't want to show its output on terminal.
For example :- ls > /dev/null will not produce any output on terminal.
So just use os,subprocess to execute some thing on shell and just put its o/p into /dev/null.
| 0
| 1
| 0
| 0
|
2011-02-14T20:22:00.000
| 4
| 0.148885
| false
| 4,996,852
| 0
| 0
| 0
| 2
|
In Python, what is the shortest and the standard way of calling a command through subprocess but not bothering with its output.
I tried subprocess.call however it seems to return the output. I am not bothered with that, I just need to run the program silently without the output cluttering up the screen.
If it helps, I am callling pdflatex and my intention is just to call it.
|
Can I deploy Python .pyc files only to Google App Engine?
| 5,002,563
| 0
| 2
| 2,724
| 0
|
python,django,google-app-engine,pyc
|
Why would you want to do that in the first place? Because your .py files are uploaded to Google infrastructure and can be seen only if you explicitly give permissions.
But yes, there is no reason as why uploading only .pyc files should not work. If you try it, in your dev environment, you will find it working just as BaseHTTPServer can take python compiled modules as handlers.
Also, recent GAE supports automatic precompilation for python files, which means that as soon as you update your application, the python files can precompiled and served. So, you might have to play with --no_precompilation during appcfg.py upload if there was any expectation to check for .py files at the app engine end.
| 0
| 1
| 0
| 0
|
2011-02-15T10:00:00.000
| 3
| 0
| false
| 5,002,150
| 0
| 0
| 1
| 2
|
I'm working on a project utilizing Django on Google App Engine. I've been asked if some of the code can be deployed as compiled only.
So I guess the question is can I upload a .pyc file only that contains the piece of code in question? I've done a basic test with a views.pyc file in an application and things don't work. Is there some configuration or other that I can set to allow Google App Engine to just use the .pyc files?
|
Can I deploy Python .pyc files only to Google App Engine?
| 5,002,914
| 7
| 2
| 2,724
| 0
|
python,django,google-app-engine,pyc
|
No, you can't - you can only upload sourcecode. There's no good reason to do this, though: your code will be bytecode-compiled on the servers when needed, and nobody is able to access your code in any case.
| 0
| 1
| 0
| 0
|
2011-02-15T10:00:00.000
| 3
| 1
| false
| 5,002,150
| 0
| 0
| 1
| 2
|
I'm working on a project utilizing Django on Google App Engine. I've been asked if some of the code can be deployed as compiled only.
So I guess the question is can I upload a .pyc file only that contains the piece of code in question? I've done a basic test with a views.pyc file in an application and things don't work. Is there some configuration or other that I can set to allow Google App Engine to just use the .pyc files?
|
Problem with using system call to execute python script from MATLAB
| 5,007,373
| 0
| 0
| 2,383
| 0
|
python,matlab,numpy
|
The shell on your system and the shell opened by Matlab when you execute the system command are not necessarily the same.
Importantly, there could be different environment variables. Try e.g. executing system('echo $PATH') to check whether you have access to all your libraries.
| 0
| 1
| 0
| 1
|
2011-02-15T17:01:00.000
| 2
| 0
| false
| 5,006,837
| 0
| 0
| 0
| 1
|
I have a MATLAB function that needs to communicate (not rapidly, and not often) with python code. I have MATLAB write numbers to a file. Python reads the file, does some calculations, and writes some results to another file. MATLAB then reads that file and continues on its way.
The problem I am having is when I want to execute the python script from MATLAB. I have found in the past that simply performing a system call within MATLAB has been sufficient:
system('python myscript.py')
However, it seems to not like the numpy function 'loadtxt' when it reaches that point in the python script:
NameError: name 'loadtxt' is not defined
I am defining it (from numpy import *). If I just execute the script from terminal, it reads in the file using loadtxt just fine. It is only when I execute the script using the system call do I get that error. The python .py file is in the same directory as the MATLAB .m file that is making the system call. I have executed other scripts without loadtxt just fine using this same method.
Any suggestions?
|
Managing two instances of the same GAE application
| 5,012,278
| 1
| 2
| 74
| 0
|
python,google-app-engine
|
Assuming you are avoiding Nick's suggestion for some particular reason, the next best thing would be to include the copying process in your build system. 1 When you build your deploy target, maven/make/ant/"your favorite build tool" should check out copies of your latest revision from your source control system into separate directories, then copy in or rename the appropriate yaml files. 2
You do have an automated build process, right? If not that should be very high on your list if you are striving for elegance.
You are using source control, right? I refuse to entertain the notion that you aren't, because that would be downright ridiculous.
| 0
| 1
| 0
| 0
|
2011-02-15T23:52:00.000
| 3
| 0.066568
| false
| 5,010,906
| 0
| 0
| 1
| 1
|
I have an GAE app, and I deploy it on 2 different domains, and they use separate datastores.
However, right now it is done by having two identical folders with different app.yaml configurations.
If I make changes I need to copy all files again. Is there an elegant solution for that, like having two app.yaml files in the same folder?
|
python tornado setup
| 12,342,342
| 1
| 5
| 4,348
| 0
|
python,tornado
|
Use Django.
I'm a hardcore Tornado fan but if you need to ask, Django is the best tool for you. Tornado is great but Django is much easier to build when you need a MySQL database thanks to its awesome ORM.
| 0
| 1
| 0
| 1
|
2011-02-16T00:25:00.000
| 5
| 1.2
| true
| 5,011,135
| 0
| 0
| 0
| 4
|
I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)
Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?
|
python tornado setup
| 31,242,703
| 0
| 5
| 4,348
| 0
|
python,tornado
|
If you are using tornado follow nginx.
| 0
| 1
| 0
| 1
|
2011-02-16T00:25:00.000
| 5
| 0
| false
| 5,011,135
| 0
| 0
| 0
| 4
|
I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)
Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?
|
python tornado setup
| 8,414,532
| 1
| 5
| 4,348
| 0
|
python,tornado
|
if you using tornado for websockets you can use ha-proxy for proxying socket request to tornado (ngnix not support this)
| 0
| 1
| 0
| 1
|
2011-02-16T00:25:00.000
| 5
| 0.039979
| false
| 5,011,135
| 0
| 0
| 0
| 4
|
I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)
Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?
|
python tornado setup
| 7,278,376
| 0
| 5
| 4,348
| 0
|
python,tornado
|
If you setup tornado via LAMP (apache with mod_wsgi for example) you will lose every single async option in tornado, significant amount of memory and speed.
It's highly recomended to use nginx for serving static files and proxying dynamic requests to the tornado application instance.
| 0
| 1
| 0
| 1
|
2011-02-16T00:25:00.000
| 5
| 0
| false
| 5,011,135
| 0
| 0
| 0
| 4
|
I want to use a Python framework that handles sessions (user auth), templating along with MySQL database access (although I can use MySQLdb quite nicely)
Tornado looks promising but, I just can't see how to use it. The sample given has a port listen feature. Does it replace Apache? Exactly how do I configure my server (Centos 5.4) and LAMP setup for this, or is there a better option?
|
If a command line program is unsure of stdout's encoding, what encoding should it output?
| 5,013,663
| 1
| 7
| 430
| 0
|
python,linux,shell,command-line,unicode
|
if your application doesn't really deal with a whole lot of internationalisation, ascii should suffice. but if not, i'd say utf-8 or better still utf-16 should be the order of the day.
| 0
| 1
| 0
| 1
|
2011-02-16T07:22:00.000
| 4
| 0.049958
| false
| 5,013,599
| 1
| 0
| 0
| 2
|
I have a command line program written in Python, and when I pipe it through another program on the command line, sys.stdout.encoding is None. This makes sense, I suppose -- the output could be another program, or a file you're redirecting it into, or whatever, and it doesn't know what encoding is desired. But neither do I! This program will be used by many different people (humor me) in different ways. Should I play it safe and output only ascii (replacing non-ascii chars with question marks)? Or should I output UTF-8, since it's so widespread these days?
|
If a command line program is unsure of stdout's encoding, what encoding should it output?
| 5,013,662
| 0
| 7
| 430
| 0
|
python,linux,shell,command-line,unicode
|
You should output UTF-8 because thats what everyone should be using. It's a bug not to be. ;)
| 0
| 1
| 0
| 1
|
2011-02-16T07:22:00.000
| 4
| 0
| false
| 5,013,599
| 1
| 0
| 0
| 2
|
I have a command line program written in Python, and when I pipe it through another program on the command line, sys.stdout.encoding is None. This makes sense, I suppose -- the output could be another program, or a file you're redirecting it into, or whatever, and it doesn't know what encoding is desired. But neither do I! This program will be used by many different people (humor me) in different ways. Should I play it safe and output only ascii (replacing non-ascii chars with question marks)? Or should I output UTF-8, since it's so widespread these days?
|
Availability of IP Address - Python
| 5,642,044
| 1
| 1
| 4,550
| 0
|
python,networking,ip-address,static-ip-address
|
This is so bad in so many ways I can't even explain how awfull this is.
Why do you want this? Could you please tell us that, and we could come up with a much better answer than this utterly uggly "sollution"?
If you have a Linux/Unix system, you can make your DHCP client to request the DHCP-server to give you a specific IP address if the DHCP server know it's free. How to do this depends on the distribution.
There are two problems I see that you will create with your "sollution".
As some other has written, you could check to see that the IP is "free" right now, but the machine that own that IP address might start right after your test. Using its IP address, wich you have kidnapped.
If the DHCP server don't know that you have kidnapped an IP address, it could give it out to someone else.
Whatever it will break the network for that computer and yours, generating lots of work, and possible anger for/to the network administrator. And you don't want that, do you?
| 0
| 1
| 0
| 0
|
2011-02-17T02:33:00.000
| 3
| 0.066568
| false
| 5,024,478
| 0
| 0
| 0
| 1
|
How to check the availability of an IP address in python?
For example, I wan't to change my system's IP address to 192.168.112.226 statically overriding the dhcp provided address. The default gateway is 192.168.112.1. But I wan't to check before if anyone is using 192.168.112.226 before assigning to myself.
Usually do this in command line from bash. I check with ping 192.168.112.226. If host is unreachable, I use 'ifconfig' and 'route' to assign it to myself.
How to automate this using python?
PS: I prefer python so that I can use python-notify to beautify the output whether success or failure.
|
Non-blocking http server , java nio , python tornado eventlet
| 5,049,188
| 4
| 4
| 2,292
| 0
|
java,python,http,asynchronous,nonblocking
|
Nonblocking servers are the best choice provided all your libraries provides nonblocking apis. As mentioned in your second question if a library blocks (eg database lib making a blocking call), the entire process/thread blocks and the system hangs. Not all of the libraries available are asynchronous which makes it difficult to use tornado/eventlet for all usecases. Also in a multi-core box multiple instances of nonblocking servers needs to be started to use the box capacity completly.
Tornado/Event servers are similar to java nio based servers. There is one conceptual difference between a Tornado and Eventlet. Tornado follows a reactor pattern where the single process waits for IO(socket) events and dispatches them to appropriate handlers. If handlers are nonblocking, best performance can be expected. Typically code written for these frameworks consists of a series of callbacks making it a bit less readable than a synchronous server .Java NIO servers comes under this category.
Eventlet performs the same task but with a cleaner interface. Code can be written as in the case of synchronous server without using callbacks. When an IO is encountered, eventlet schedules another userspace process(not right terminology).
Apache webapps are more popular that these because of few reasons
It is relatively easy to write synchronous code
Not all required libraries are asynchronous.
But for writing a chat application which handles lots of connections a multi-threaded server will not scale. You have to use async frameworks like twisted/event/Java NIO.
| 0
| 1
| 0
| 1
|
2011-02-17T06:31:00.000
| 1
| 0.664037
| false
| 5,025,770
| 0
| 0
| 1
| 1
|
Hi
I am trying to Understand if tornado/eventlet based http sever are better than threaded sever. While goggling the subject I am seeing that these are single thread event base server which run a single handler function after select/poll/epoll on socket.
My first question is that is this tornado/eventlet similar to nio library in java and is a java nio server non-blocking and fast.
My second question is that since this event based Server are single thread If one connection blocks on file io or solw client will it hang the entire server
My third question is that what is the trade off , if non blocking server is fast why isn't it is more common than apache
These questions are related and I would apprecite as I am not understanding these issues correctly
Thanks
|
Google App Engine log username with custom auth
| 5,035,952
| 0
| 1
| 252
| 0
|
python,google-app-engine,logging
|
Add a single logging.debug call in your authentication code to log the current user. Logs are shown aggregated by request, so you'll always be able to see the user associated with that request.
| 0
| 1
| 0
| 0
|
2011-02-17T09:56:00.000
| 1
| 0
| false
| 5,027,371
| 0
| 0
| 1
| 1
|
I use a custom authentication for my python Google App Engine app.
There is a "username" field in the log for every request, which is empty now. Is it possible to add the name of the authenticated user to the log? I would not like to add an "user: %s" % user.name manually to all of my logging.xxx statements.
Thanks.
|
How to install scripts to sbin with python's distutils?
| 7,715,650
| 1
| 5
| 2,055
| 0
|
python,installation,distutils
|
For distutils, we are working on support to install scripts into prefix/sbin.
| 0
| 1
| 0
| 0
|
2011-02-17T11:02:00.000
| 2
| 0.099668
| false
| 5,028,075
| 0
| 0
| 0
| 1
|
Commonly on most unix systems there is a distinction between $PREFIX/bin and $PREFIX/sbin. When installing a piece of software the administrator decides about what $PREFIX is, but the author decides which programs are suitable for regular users and which are not. With Python's distutils a set of scripts can be defined and they are installed to $PREFIX/bin. So how to install a script to the corresponding sbin directory?
Note that in this case solutions targeting only Linux are welcome, because other parts of the software in question depend on iptables.
|
create subprocess object from already running process
| 5,030,603
| 2
| 3
| 2,491
| 0
|
python,process,popen
|
Assuming you want to communicate with the "subprocess" and must do so using its standard i/o streams, you could create a wrapper around the executable that maps its stdin/out/err to a socket or named pipe.
The program that intends to control the "subprocess" can then start and stop communications at any time. You may have to provide for a locking mechanism too.
Then, assuming you're on Linux, you can access the stdin/out/err of a running process through /proc/<pid>/fd/<0,1,2>. You won't connect these to a subprocess.Popen object but open('/proc/<pid>/fd/1', 'rb') will behave like Popen().stdout.
| 0
| 1
| 0
| 0
|
2011-02-17T13:59:00.000
| 2
| 0.197375
| false
| 5,029,880
| 0
| 0
| 0
| 2
|
I would like to create an subprocess.Popen object from an already running process... Is that possible somehow?
Another idea would be to serialize (pickle) the subprocess object and write it to a database so that if the main process restarts it could get the subprocess.Popen objects back from the database. I'm unsure if that works.
|
create subprocess object from already running process
| 5,030,048
| 2
| 3
| 2,491
| 0
|
python,process,popen
|
create an subprocess.Popen object from an already running process
Do you mean from an already running sub-process? The only way I know of to pass objects between processes is to pickle them and write them out either to a file or a database as you suggested.
Typically, sub-processes cannot be spawned from already running sub-processes, but you can keep a reference to the new process you want to create and spawn it from the main process. This could get really ugly, and I suggest against it strongly. Why, specifically do you need to further your process tree past two-deep? This info might lead to a better answer.
| 0
| 1
| 0
| 0
|
2011-02-17T13:59:00.000
| 2
| 0.197375
| false
| 5,029,880
| 0
| 0
| 0
| 2
|
I would like to create an subprocess.Popen object from an already running process... Is that possible somehow?
Another idea would be to serialize (pickle) the subprocess object and write it to a database so that if the main process restarts it could get the subprocess.Popen objects back from the database. I'm unsure if that works.
|
Elegant Way To Share Variable Between Windows Form and Python Script Running In Background Process
| 5,031,228
| 1
| 3
| 580
| 0
|
python,winforms,global-variables
|
Easiest solution is probably to just have the python script print to stdout: say each time an item is processed, print a line with a number representing how many items have been processed (or a percentage). Then have the forms application read the output line by line, updating the progressbar based on that information.
| 0
| 1
| 0
| 0
|
2011-02-17T14:58:00.000
| 2
| 1.2
| true
| 5,030,586
| 0
| 0
| 0
| 1
|
I am trying to figure out an elegant way to share a variable between a windows form app and a python script running in the background. The variable would be used solely to update a progress bar in the windows form based on the the long running process in the python script. More specifically, a windows timer will fire every n seconds, check the variable, then update the progress bar value. Sound stupid enough yet? I'll try to explain the need for this below.
I have a windows app that lets a user define a number of parameters to fire off a long running process (python script). Without getting into unnecessary detail, this long running process will insert many (100k+ records) into a sqlite database over a significant period of time. In order to make the python script as performant as possible, I don't call commit on the sqlite database until the very end of the python script. Trying to query the sqlite database from the windows app (via System.Data.Sqlite) before the commit occurs always yields 0 records, regardless of far along the process is.
The windows app will know how many total records will be inserted by the python process, so determining progress will be straight-forward enough, assuming I can get access to a record count in the python script.
I know I could do this with a text file, but is there any better way?
|
Is it possible to 'import * from DIRECTORY', then somehow (anyhow) iterate over the loaded modules?
| 5,054,203
| 4
| 0
| 210
| 0
|
python,google-app-engine,import
|
You can read from the filesystem in GAE just fine; you just can't write to the filesystem.
from models import * will only import modules listed in __all__ in models/__init__.py; there's no automatic way to import all modules in a package if they're not declared to be part of the package. You just need to read the directory (which you can do) and __import__() everything in it.
| 0
| 1
| 0
| 0
|
2011-02-19T23:24:00.000
| 3
| 1.2
| true
| 5,054,191
| 0
| 0
| 1
| 1
|
Let me explain the use case...
In a simple python web application framework designed for Google App Engine, I'd like to have my models loaded automatically from a 'models' directory, so all that's needed to add a model to the application is place a file user.py (for example), which contains a class called 'User', in the 'models/' directory.
Being GAE, I can't read from the file system so I can't just read the filenames that way, but it seems to me that I must be able to 'import * from models' (or some equivalent), and retrieve at least a list of module names that were loaded, so I can subject them to further processing logic.
To be clear, I want this to be done WITHOUT having to maintain a separate list of these module names for the application to read from.
|
Update app engine entity
| 5,720,652
| 2
| 4
| 6,215
| 0
|
python,google-app-engine
|
I use GQL to query a find the Entity and if exists update de atribute.
result = db.GqlQuery('select name from Person where name = "tadeu"')
if result:
for r in result:
r.attribute = "value"
r.put()
| 0
| 1
| 0
| 0
|
2011-02-21T13:12:00.000
| 4
| 0.099668
| false
| 5,066,357
| 0
| 0
| 1
| 1
|
How to update existing record in app engine.
|
Pylons - how to use an old project in a new environment?
| 5,067,114
| 1
| 2
| 68
| 0
|
python,project,upgrade,pylons
|
might be obvious but did you run "python setup.py develop" on the application package so that the dependencies could be installed?
| 0
| 1
| 0
| 1
|
2011-02-21T13:28:00.000
| 1
| 0.197375
| false
| 5,066,530
| 0
| 0
| 1
| 1
|
I have an old project, it written under Python 2.5/2.6, Windows.
We had Python 2.6/Win7/x64 now, and I tried to start it.
I got the old project that running nondebug mode in a server, and
copied into local folder.
When I tried to yesterday start it, I got this error:
15:44:58,038 DEBUG [pylons.configuration] Loaded None template engine
as the default template renderer
I see the google, but they are points to config.init_app, that is does
not exists.
TOday I reinstalled Python, but with Py2.7, pylons and mako.
But when I tried to stat it, I got only this message:
07:36:36,377 DEBUG [pylons.configuration] Initializing configuration,
package: 'x'
And no more information about die... :-(
So what do you meaning, how can I raise this "undead" project to debug
some things?
( it was good experience with Python/Pylons, but I'm sad now that I
not choose PHP previously, because of package changes).
Thanks:
dd
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.