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
List of IP addresses/hostnames from local network in Python
207,246
24
46
129,230
0
python,networking
If by "local" you mean on the same network segment, then you have to perform the following steps: Determine your own IP address Determine your own netmask Determine the network range Scan all the addresses (except the lowest, which is your network address and the highest, which is your broadcast address). Use your DNS's reverse lookup to determine the hostname for IP addresses which respond to your scan. Or you can just let Python execute nmap externally and pipe the results back into your program.
0
1
1
0
2008-10-16T02:32:00.000
11
1.2
true
207,234
0
0
0
1
How can I get a list of the IP addresses or host names from a local network easily in Python? It would be best if it was multi-platform, but it needs to work on Mac OS X first, then others follow. Edit: By local I mean all active addresses within a local network, such as 192.168.xxx.xxx. So, if the IP address of my computer (within the local network) is 192.168.1.1, and I have three other connected computers, I would want it to return the IP addresses 192.168.1.2, 192.168.1.3, 192.168.1.4, and possibly their hostnames.
Using os.execvp in Python
211,898
0
7
11,349
0
python,shell,exec
Make sure you aren't relying on shell expansion in your classpath. E.g. "~/my.jar" will get expanded by the shell in an os.system call, but not, I believe in an os.execvp call.
0
1
0
0
2008-10-17T03:04:00.000
2
0
false
210,978
0
0
1
1
I have a question about using os.execvp in Python. I have the following bit of code that's used to create a list of arguments: args = [ "java" , classpath , "-Djava.library.path=" + lib_path() , ea , "-Xmx1000m" , "-server" , "code_swarm" , params ] When I output a string using " ".join(args) and paste that into my shell prompt, the JVM launches fine, and everything works. Everything works if I use os.system(" ".join(args)) in my Python script, too. But the following bit of code does not work: os.execvp("java", args) I get the following error: Unrecognized option: -classpath [and then the classpath I created, which looks okay] Could not create the Java virtual machine. So what gives? Why does copying/pasting into the shell or using os.system() work, but not os.execvp()?
How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?
406,119
0
1
2,011
0
python,configuration,trac,python-egg-cache
I found that using the PythonOption directive in the site config did not work, but SetEnv did. The environment variable route will also work though.
0
1
0
1
2008-10-18T16:51:00.000
5
0
false
215,267
0
0
0
3
We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in: PythonHandler trac.web.modpython_frontend: ExtractionError: Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/.python-eggs' The Python egg cache directory is currently set to: /.python-eggs Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory So I explicitly set PYTHON_EGG_CACHE to /srv/trac/plugin-cache. I restarted Apache. Yet I get the same error (it still says "egg cache directory current set to: \n\n /.python_eggs.") How should I proceed? Is the simplest thing to do to reinstall Trac? If I go that route, what steps do I need to take to ensure that I don't lose existing data?
How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?
219,233
0
1
2,011
0
python,configuration,trac,python-egg-cache
I had the same problem. In my case the directory wasn't there so I created and chown'ed it over to the apache user (apache on my centos 4.3 box). Then made sure it had read-write permissions on the directory. You could get by with giving rw rights to the directory if the group that owns the directory contains the apache user. A simple ps aux|grep httpd should show you what account your server is running under if you don't know it. If you have trouble finding the directory remember the -a on the ls command since it is a "hidden" directory.
0
1
0
1
2008-10-18T16:51:00.000
5
0
false
215,267
0
0
0
3
We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in: PythonHandler trac.web.modpython_frontend: ExtractionError: Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/.python-eggs' The Python egg cache directory is currently set to: /.python-eggs Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory So I explicitly set PYTHON_EGG_CACHE to /srv/trac/plugin-cache. I restarted Apache. Yet I get the same error (it still says "egg cache directory current set to: \n\n /.python_eggs.") How should I proceed? Is the simplest thing to do to reinstall Trac? If I go that route, what steps do I need to take to ensure that I don't lose existing data?
How do you fix a Trac installation that begins giving errors relating to PYTHON_EGG_CACHE?
215,401
1
1
2,011
0
python,configuration,trac,python-egg-cache
I have wrestled many a battle with PYTHON_EGG_CACHE and I never figured out the correct way of setting it - apache's envvars, httpd.conf (SetEnv and PythonOption), nothing worked. In the end I just unpacked all python eggs manually, there were only two or three anyway - problem gone. I never understood why on earth people zip up files weighting no more than a few kilobytes in the first place...
0
1
0
1
2008-10-18T16:51:00.000
5
0.039979
false
215,267
0
0
0
3
We've been using Trac for task/defect tracking and things were going well enough, but this morning it started serving up a 500 error. Looking in the Apache error_log, I get a stack trace that culminates in: PythonHandler trac.web.modpython_frontend: ExtractionError: Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg cache: [Errno 13] Permission denied: '/.python-eggs' The Python egg cache directory is currently set to: /.python-eggs Perhaps your account does not have write access to this directory? You can change the cache directory by setting the PYTHON_EGG_CACHE environment variable to point to an accessible directory So I explicitly set PYTHON_EGG_CACHE to /srv/trac/plugin-cache. I restarted Apache. Yet I get the same error (it still says "egg cache directory current set to: \n\n /.python_eggs.") How should I proceed? Is the simplest thing to do to reinstall Trac? If I go that route, what steps do I need to take to ensure that I don't lose existing data?
What's the difference between a parent and a reference property in Google App Engine?
216,187
15
10
1,067
1
python,api,google-app-engine
There are several differences: All entities with the same ancestor are in the same entity group. Transactions can only affect entities inside a single entity group. All writes to a single entity group are serialized, so throughput is limited. The parent entity is set on creation and is fixed. References can be changed at any time. With reference properties, you can only query for direct relationships, but with parent properties you can use the .ancestor() filter to find everything (directly or indirectly) descended from a given ancestor. Each entity has only a single parent, but can have multiple reference properties.
0
1
0
0
2008-10-18T21:12:00.000
2
1.2
true
215,570
0
0
1
1
From what I understand, the parent attribute of a db.Model (typically defined/passed in the constructor call) allows you to define hierarchies in your data models. As a result, this increases the size of the entity group. However, it's not very clear to me why we would want to do that. Is this strictly for ACID compliance? I would like to see scenarios where each is best suited or more appropriate.
Ensure a single instance of an application in Linux
220,536
0
33
22,567
0
python,linux,single-instance
If you create a lock file and put the pid in it, you can check your process id against it and tell if you crashed, no? I haven't done this personally, so take with appropriate amounts of salt. :p
0
1
0
0
2008-10-21T01:58:00.000
12
0
false
220,525
0
0
0
4
I'm working on a GUI application in WxPython, and I am not sure how I can ensure that only one copy of my application is running at any given time on the machine. Due to the nature of the application, running more than once doesn't make any sense, and will fail quickly. Under Win32, I can simply make a named mutex and check that at startup. Unfortunately, I don't know of any facilities in Linux that can do this. I'm looking for something that will automatically be released should the application crash unexpectedly. I don't want to have to burden my users with having to manually delete lock files because I crashed.
Ensure a single instance of an application in Linux
220,709
62
33
22,567
0
python,linux,single-instance
The Right Thing is advisory locking using flock(LOCK_EX); in Python, this is found in the fcntl module. Unlike pidfiles, these locks are always automatically released when your process dies for any reason, have no race conditions exist relating to file deletion (as the file doesn't need to be deleted to release the lock), and there's no chance of a different process inheriting the PID and thus appearing to validate a stale lock. If you want unclean shutdown detection, you can write a marker (such as your PID, for traditionalists) into the file after grabbing the lock, and then truncate the file to 0-byte status before a clean shutdown (while the lock is being held); thus, if the lock is not held and the file is non-empty, an unclean shutdown is indicated.
0
1
0
0
2008-10-21T01:58:00.000
12
1
false
220,525
0
0
0
4
I'm working on a GUI application in WxPython, and I am not sure how I can ensure that only one copy of my application is running at any given time on the machine. Due to the nature of the application, running more than once doesn't make any sense, and will fail quickly. Under Win32, I can simply make a named mutex and check that at startup. Unfortunately, I don't know of any facilities in Linux that can do this. I'm looking for something that will automatically be released should the application crash unexpectedly. I don't want to have to burden my users with having to manually delete lock files because I crashed.
Ensure a single instance of an application in Linux
220,541
0
33
22,567
0
python,linux,single-instance
By far the most common method is to drop a file into /var/run/ called [application].pid which contains only the PID of the running process, or parent process. As an alternative, you can create a named pipe in the same directory to be able to send messages to the active process, e.g. to open a new file.
0
1
0
0
2008-10-21T01:58:00.000
12
0
false
220,525
0
0
0
4
I'm working on a GUI application in WxPython, and I am not sure how I can ensure that only one copy of my application is running at any given time on the machine. Due to the nature of the application, running more than once doesn't make any sense, and will fail quickly. Under Win32, I can simply make a named mutex and check that at startup. Unfortunately, I don't know of any facilities in Linux that can do this. I'm looking for something that will automatically be released should the application crash unexpectedly. I don't want to have to burden my users with having to manually delete lock files because I crashed.
Ensure a single instance of an application in Linux
220,542
25
33
22,567
0
python,linux,single-instance
There are several common techniques including using semaphores. The one I see used most often is to create a "pid lock file" on startup that contains the pid of the running process. If the file already exists when the program starts up, open it up and grab the pid inside, check to see if a process with that pid is running, if it is check the cmdline value in /proc/pid to see if it is an instance of your program, if it is then quit, otherwise overwrite the file with your pid. The usual name for the pid file is application_name.pid.
0
1
0
0
2008-10-21T01:58:00.000
12
1.2
true
220,525
0
0
0
4
I'm working on a GUI application in WxPython, and I am not sure how I can ensure that only one copy of my application is running at any given time on the machine. Due to the nature of the application, running more than once doesn't make any sense, and will fail quickly. Under Win32, I can simply make a named mutex and check that at startup. Unfortunately, I don't know of any facilities in Linux that can do this. I'm looking for something that will automatically be released should the application crash unexpectedly. I don't want to have to burden my users with having to manually delete lock files because I crashed.
Is it possible to set a timeout on a socket in Twisted?
24,895,751
0
9
7,051
0
python,networking,sockets,twisted
A better way to do this is with twisted.protocols.policies.TimeoutMixin. It's essentially doing a callLater but abstracted into a Mixin.
0
1
0
0
2008-10-21T12:56:00.000
4
0
false
221,745
0
0
0
1
I realize I'm probably just dumb and missing something big and important, but I can't figure out how to specify a timeout in twisted using reactor.listenUDP. My goal is to be able to specify a timeout, and after said amount of time, if DatagramProtocol.datagramReceived has not been executed, have it execute a callback or something that I can use to call reactor.stop(). Any help or advice is appreciated. Thanks
How do I get file creation and modification date/times?
367,166
-3
1,205
1,083,080
0
python,file
os.stat does include the creation time. There's just no definition of st_anything for the element of os.stat() that contains the time. So try this: os.stat('feedparser.py')[8] Compare that with your create date on the file in ls -lah They should be the same.
0
1
0
1
2008-10-25T21:54:00.000
12
-0.049958
false
237,079
0
0
0
2
What's the best cross-platform way to get file creation and modification dates/times, that works on both Linux and Windows?
How do I get file creation and modification date/times?
237,093
13
1,205
1,083,080
0
python,file
os.stat returns a named tuple with st_mtime and st_ctime attributes. The modification time is st_mtime on both platforms; unfortunately, on Windows, ctime means "creation time", whereas on POSIX it means "change time". I'm not aware of any way to get the creation time on POSIX platforms.
0
1
0
1
2008-10-25T21:54:00.000
12
1
false
237,079
0
0
0
2
What's the best cross-platform way to get file creation and modification dates/times, that works on both Linux and Windows?
How can I call a DLL from a scripting language?
239,098
4
9
3,922
0
python,perl,dll
For Python, you could compile an extension which links to the DLL, so that in Python you could just import it like a normal module. You could do this by hand, by using a library like Boost.Python, or by using a tool such as SWIG (which also supports Perl and other scripting languages) to generate a wrapper automatically.
0
1
0
1
2008-10-27T03:42:00.000
5
0.158649
false
239,020
0
0
0
1
I have a third-party product, a terminal emulator, which provides a DLL that can be linked to a C program to basically automate the driving of this product (send keystrokes, detect what's on the screen and so forth). I want to drive it from a scripting language (I'm comfortable with Python and slightly less so with Perl) so that we don't have to compile and send out executables to our customers whenever there's a problem found. We also want the customers to be able to write their own scripts using ours as baselines and they won't entertain the idea of writing and compiling C code. What's a good way of getting Python/Perl to interface to a Windows DLL. My first thought was to write a server program and have a Python script communicate with it via TCP but there's got to be an easier solution.
Possible to integrate Google AppEngine and Google Code for continuous integration?
241,672
1
18
2,320
0
python,svn,google-app-engine,continuous-integration,google-code
For those of us who are using Github, this feature from the GAE team would make us all seriously consider switching to Google Code...
0
1
0
0
2008-10-27T18:43:00.000
5
0.039979
false
241,007
0
0
1
2
Anyone have any thoughts on how/if it is possible to integrate Google Code commits to cause a Google AppEngine deployment of the most recent code? I have a simple Google AppEngine project's source hosted on Google Code and would love if everytime I committed to Subversion, that AppEngine would reflect the latest commit. I don't mind if things are broken on the live site since the project is for personal use mainly and for learning. Anyone have any thoughts on how to tie into the subversion commit for the Code repository and/or how to kickoff the deployment to AppEngine? Ideally the solution would not require anything manual from me nor any type of server/listener software on my machine.
Possible to integrate Google AppEngine and Google Code for continuous integration?
241,126
1
18
2,320
0
python,svn,google-app-engine,continuous-integration,google-code
Very interesting, but not yet possible, AFAIK. I have been looking for that option in Google Code with no success. The only solution I can figure out is to install something in your machine that checks for changes in your SVN repository. I'll be happy to hear about other approaches.
0
1
0
0
2008-10-27T18:43:00.000
5
0.039979
false
241,007
0
0
1
2
Anyone have any thoughts on how/if it is possible to integrate Google Code commits to cause a Google AppEngine deployment of the most recent code? I have a simple Google AppEngine project's source hosted on Google Code and would love if everytime I committed to Subversion, that AppEngine would reflect the latest commit. I don't mind if things are broken on the live site since the project is for personal use mainly and for learning. Anyone have any thoughts on how to tie into the subversion commit for the Code repository and/or how to kickoff the deployment to AppEngine? Ideally the solution would not require anything manual from me nor any type of server/listener software on my machine.
OpenGl with Python
242,063
1
15
18,416
0
python,opengl,fedora
What OpenGL library are you using? What windowing library? What version of Python? Most likely cause I can think of is that your windowing library (SDL or whatever you're using) isn't initializing OpenGL before you start calling into it.
1
1
0
0
2008-10-28T02:29:00.000
6
0.033321
false
242,059
0
0
0
5
I am currently in a course that is using OpenGL and I have been using C for all the programs so far. I have Python installed on Fedora as well as OpenGL, however the minute I call an OpenGL command in my Python code, I get a segmentation fault. I have no idea why this is. Just to avoid the "just use C" comments, here is why I want to use Python: There are a couple reasons I am wanting to switch from C to Python, but the main one is because we are about to start writing a raytracer and I would like to use classes to make it easier on me. Since I hate classes in C++ and structs in C seems a little crazy, I thought I would give Python a try at it. I have also been looking for a reason to use Python again as it has been a while. Thanks for any help.
OpenGl with Python
242,371
0
15
18,416
0
python,opengl,fedora
We have neither ideas about random segmentation faults. There is not enough information. What python libraries are you using for opengl? How do you use them? Can you show us your code? It's probably something trivial but my god -skill ends up to telling me just and only that. Raytracer in python? I'd prefer just doing that in C with those structs. But then, I'm assuming you aren't going to do a realtime raytracer so that may be ok.
1
1
0
0
2008-10-28T02:29:00.000
6
0
false
242,059
0
0
0
5
I am currently in a course that is using OpenGL and I have been using C for all the programs so far. I have Python installed on Fedora as well as OpenGL, however the minute I call an OpenGL command in my Python code, I get a segmentation fault. I have no idea why this is. Just to avoid the "just use C" comments, here is why I want to use Python: There are a couple reasons I am wanting to switch from C to Python, but the main one is because we are about to start writing a raytracer and I would like to use classes to make it easier on me. Since I hate classes in C++ and structs in C seems a little crazy, I thought I would give Python a try at it. I have also been looking for a reason to use Python again as it has been a while. Thanks for any help.
OpenGl with Python
246,922
0
15
18,416
0
python,opengl,fedora
Perhaps you are calling an OpenGL function that requires an active OpenGL context, without having one? That shouldn't necessarily crash, but I guess it might. How to set up such a context depends on the platform, and it's been a while since I used GL from Python (and when I did, I also used GTK+ which complicates matters).
1
1
0
0
2008-10-28T02:29:00.000
6
0
false
242,059
0
0
0
5
I am currently in a course that is using OpenGL and I have been using C for all the programs so far. I have Python installed on Fedora as well as OpenGL, however the minute I call an OpenGL command in my Python code, I get a segmentation fault. I have no idea why this is. Just to avoid the "just use C" comments, here is why I want to use Python: There are a couple reasons I am wanting to switch from C to Python, but the main one is because we are about to start writing a raytracer and I would like to use classes to make it easier on me. Since I hate classes in C++ and structs in C seems a little crazy, I thought I would give Python a try at it. I have also been looking for a reason to use Python again as it has been a while. Thanks for any help.
OpenGl with Python
1,778,664
2
15
18,416
0
python,opengl,fedora
Well, I don't know if these are the libs the original poster are using but I saw identical issues in a pet project I'm working on (Graphics Engine using C++ and Python) using PyOpenGL. PyOpenGL didn't correctly pick up the rendering context if it was created after the python script had been loaded (I was loading the script first, then calling Python methods in it from my C++ code). The problem doesn't appear if you initialize the display and create the OpenGL rendering context before loading the Python script.
1
1
0
0
2008-10-28T02:29:00.000
6
0.066568
false
242,059
0
0
0
5
I am currently in a course that is using OpenGL and I have been using C for all the programs so far. I have Python installed on Fedora as well as OpenGL, however the minute I call an OpenGL command in my Python code, I get a segmentation fault. I have no idea why this is. Just to avoid the "just use C" comments, here is why I want to use Python: There are a couple reasons I am wanting to switch from C to Python, but the main one is because we are about to start writing a raytracer and I would like to use classes to make it easier on me. Since I hate classes in C++ and structs in C seems a little crazy, I thought I would give Python a try at it. I have also been looking for a reason to use Python again as it has been a while. Thanks for any help.
OpenGl with Python
2,284,461
0
15
18,416
0
python,opengl,fedora
Scripts never cause segmentation faults. But first see if your kernel and kmod video driver working property ... Extension modules can cause "segmentation fault".
1
1
0
0
2008-10-28T02:29:00.000
6
0
false
242,059
0
0
0
5
I am currently in a course that is using OpenGL and I have been using C for all the programs so far. I have Python installed on Fedora as well as OpenGL, however the minute I call an OpenGL command in my Python code, I get a segmentation fault. I have no idea why this is. Just to avoid the "just use C" comments, here is why I want to use Python: There are a couple reasons I am wanting to switch from C to Python, but the main one is because we are about to start writing a raytracer and I would like to use classes to make it easier on me. Since I hate classes in C++ and structs in C seems a little crazy, I thought I would give Python a try at it. I have also been looking for a reason to use Python again as it has been a while. Thanks for any help.
Is there something between a normal user account and root?
248,874
0
3
1,208
0
python,linux,root
I'm not familiar enough with Python to tell you what the necessary commands would be in that language, but you should be able to accomplish this by forking and using a pipe to communicate between the parent and child processes. Something along the lines of: Run the program as root via sudo or suid On startup, the program immediately forks and establishes a pipe for communication between the parent and child processes The child process retains root power, but just sits there waiting for input from the pipe The parent process drops root (changes its uid back to that of the user running it), then displays the GUI, interacts with the user, and handles all operations which are available to a non-privileged user When an operation is to be performed which requires root privileges, the (non-root) parent process sends a command down the pipe to the (root) child process which executes it and optionally reports back to the parent This is likely to be a bit easier to write than an independent daemon, as well as more convenient to run (since you don't need to worry about whether the daemon is running or not), while also allowing the GUI and other things which don't need root powers to be run as non-root.
0
1
0
0
2008-10-29T23:02:00.000
7
0
false
248,730
0
0
0
6
I'm developing an application that manages network interfaces on behalf of the user and it calls out to several external programs (such as ifconfig) that requires root to make changes. (Specifically, changing the IP address of a local interface, etc.) During development, I have been running the IDE as root (ugh) and the debugger as root (double-ugh). Is there a nice way for the end-user to run these under a non-root account? I strongly dislike the size of the attack surface presented by GTK, wxPython, Python, and my application when it runs as root. I have looked into capabilities, but they look half-baked and I'm not sure if I'd be able to use them in Python, especially if they are on a thread basis. The only option I haven't explored is a daemon that has the setuid bit set and does all the root-type stuff on behalf of the UI. I'm hesitant to introduce that complexity this early in the project, as running as root is not a dealbreaker for the users.
Is there something between a normal user account and root?
248,759
3
3
1,208
0
python,linux,root
What you want is a "Group" You create a group, specify that the account wanting to do the action belongs to the group, then you specify that the resource you want access to is a member of that group. Sometimes group management can be kind of irritating, but it should allow you to do anything you want, and it's the user that is authorized, not your program. (If you want your program authorized, you can create a specific user to run it as and give that user the proper group membership, then su to that group within your program to execute the operation without giving the running user the ability.)
0
1
0
0
2008-10-29T23:02:00.000
7
0.085505
false
248,730
0
0
0
6
I'm developing an application that manages network interfaces on behalf of the user and it calls out to several external programs (such as ifconfig) that requires root to make changes. (Specifically, changing the IP address of a local interface, etc.) During development, I have been running the IDE as root (ugh) and the debugger as root (double-ugh). Is there a nice way for the end-user to run these under a non-root account? I strongly dislike the size of the attack surface presented by GTK, wxPython, Python, and my application when it runs as root. I have looked into capabilities, but they look half-baked and I'm not sure if I'd be able to use them in Python, especially if they are on a thread basis. The only option I haven't explored is a daemon that has the setuid bit set and does all the root-type stuff on behalf of the UI. I'm hesitant to introduce that complexity this early in the project, as running as root is not a dealbreaker for the users.
Is there something between a normal user account and root?
248,756
1
3
1,208
0
python,linux,root
You could create and distribute a selinux policy for your application. Selinux allows the kind of fine-grained access that you need. If you can't or won't use selinux, then the daemon is the way to go.
0
1
0
0
2008-10-29T23:02:00.000
7
0.028564
false
248,730
0
0
0
6
I'm developing an application that manages network interfaces on behalf of the user and it calls out to several external programs (such as ifconfig) that requires root to make changes. (Specifically, changing the IP address of a local interface, etc.) During development, I have been running the IDE as root (ugh) and the debugger as root (double-ugh). Is there a nice way for the end-user to run these under a non-root account? I strongly dislike the size of the attack surface presented by GTK, wxPython, Python, and my application when it runs as root. I have looked into capabilities, but they look half-baked and I'm not sure if I'd be able to use them in Python, especially if they are on a thread basis. The only option I haven't explored is a daemon that has the setuid bit set and does all the root-type stuff on behalf of the UI. I'm hesitant to introduce that complexity this early in the project, as running as root is not a dealbreaker for the users.
Is there something between a normal user account and root?
248,758
7
3
1,208
0
python,linux,root
Your idea about the daemon has much merit, despite the complexity it introduces. As long as the actions don't require some user interface interaction as root, a daemon allows you to control what operations are allowed and disallowed. However, you can use SUDO to create a controlled compromise between ROOT and normal users... simply grant SUDO access to the users in question for the specific tools they need. That reduces the attack surface by allowing only "permitted" root launches.
0
1
0
0
2008-10-29T23:02:00.000
7
1.2
true
248,730
0
0
0
6
I'm developing an application that manages network interfaces on behalf of the user and it calls out to several external programs (such as ifconfig) that requires root to make changes. (Specifically, changing the IP address of a local interface, etc.) During development, I have been running the IDE as root (ugh) and the debugger as root (double-ugh). Is there a nice way for the end-user to run these under a non-root account? I strongly dislike the size of the attack surface presented by GTK, wxPython, Python, and my application when it runs as root. I have looked into capabilities, but they look half-baked and I'm not sure if I'd be able to use them in Python, especially if they are on a thread basis. The only option I haven't explored is a daemon that has the setuid bit set and does all the root-type stuff on behalf of the UI. I'm hesitant to introduce that complexity this early in the project, as running as root is not a dealbreaker for the users.
Is there something between a normal user account and root?
248,882
1
3
1,208
0
python,linux,root
The traditional way would be to create and use a setuid helper to do whatever you need. Note that, however, properly writing a setuid helper is tricky (there are several attack vectors you have to protect against). The modern way would be to use a daemon (running as root, started on boot) which listens to requests from the rest of the application. This way, your attack surface is mostly limited to whichever IPC you chose (I'd suggest d-bus, which seems to be the modern way). Finally, if you are managing network interfaces, what you doing is very similar to what network-manager does on a modern distribution. It would be a good idea to either try to somehow integrate what you are doing with network-manager (so it will not conflict with your manipulations), or at least looks at how it works.
0
1
0
0
2008-10-29T23:02:00.000
7
0.028564
false
248,730
0
0
0
6
I'm developing an application that manages network interfaces on behalf of the user and it calls out to several external programs (such as ifconfig) that requires root to make changes. (Specifically, changing the IP address of a local interface, etc.) During development, I have been running the IDE as root (ugh) and the debugger as root (double-ugh). Is there a nice way for the end-user to run these under a non-root account? I strongly dislike the size of the attack surface presented by GTK, wxPython, Python, and my application when it runs as root. I have looked into capabilities, but they look half-baked and I'm not sure if I'd be able to use them in Python, especially if they are on a thread basis. The only option I haven't explored is a daemon that has the setuid bit set and does all the root-type stuff on behalf of the UI. I'm hesitant to introduce that complexity this early in the project, as running as root is not a dealbreaker for the users.
Is there something between a normal user account and root?
248,743
0
3
1,208
0
python,linux,root
There's no single user that is halfway between a "normal" user and root. You have root, and then you have users; users can have differing levels of capabilities. If you want something that's more powerful than a "normal" user but not as powerful as root, you just create a new user with the capabilities you want, but don't give it the privileges you don't want it to have.
0
1
0
0
2008-10-29T23:02:00.000
7
0
false
248,730
0
0
0
6
I'm developing an application that manages network interfaces on behalf of the user and it calls out to several external programs (such as ifconfig) that requires root to make changes. (Specifically, changing the IP address of a local interface, etc.) During development, I have been running the IDE as root (ugh) and the debugger as root (double-ugh). Is there a nice way for the end-user to run these under a non-root account? I strongly dislike the size of the attack surface presented by GTK, wxPython, Python, and my application when it runs as root. I have looked into capabilities, but they look half-baked and I'm not sure if I'd be able to use them in Python, especially if they are on a thread basis. The only option I haven't explored is a daemon that has the setuid bit set and does all the root-type stuff on behalf of the UI. I'm hesitant to introduce that complexity this early in the project, as running as root is not a dealbreaker for the users.
OS X: Determine Trash location for a given path
249,800
2
1
3,560
0
python,macos,filesystems
The File Manager API has a pair of functions called FSMoveObjectToTrashAsync and FSPathMoveObjectToTrashSync. Not sure if that is exposed to Python or not.
0
1
0
0
2008-10-30T10:50:00.000
6
0.066568
false
249,785
0
0
0
1
Simply moving the file to ~/.Trash/ will not work, as if the file os on an external drive, it will move the file to the main system drive.. Also, there are other conditions, like files on external drives get moved to /Volumes/.Trash/501/ (or whatever the current user's ID is) Given a file or folder path, what is the correct way to determine the trash folder? I imagine the language is pretty irrelevant, but I intend to use Python
How to override HTTP request verb in GAE
255,906
3
1
1,104
0
python,google-app-engine,rest,metaclass
Calling the handler from initialize isn't the right way anyway - if you do that, the webapp will then call the original handler as well. Instead, you have a couple of options: You can subclass webapp.WSGIApplication and override call to select the method based on _method when it exists. You can check for the existence of _method in initialize, and if it exists, modify the request object's 'REQUEST_METHOD' environment variable accordingly. That will cause the WSGIApplication class to execute the method you choose. Either way, take a look at google/appengine/ext/webapp/init.py in the SDK so you can see how it works.
0
1
0
0
2008-10-31T22:37:00.000
2
0.291313
false
255,157
0
0
1
2
In the context of a Google App Engine Webapp framework application: I want to changed the request verb of a request in the case a parameter _method is provided, for example if a POST request comes in with a parameter _method=PUT, I need to change the request to call the put method of the handler. This is to cope with the way prototype.js works with verbs like PUT and DELETE(workaround for IE). Here is my first attempt: class MyRequestHandler(webapp.RequestHandler): def initialize(self, request, response): m = request.get('_method') if m: request.method = m.upper() webapp.RequestHandler.initialize(self, request, response) The problem is, for some reason whenever the redirect is done, the self.request.params are emptied by the time the handling method(put or delete) is called, even though they were populated when initialize was called. Anyone have a clue why this is? As a workaround I thought I could clone the params at initialize() time, but .copy() did not work, and I haven't found a way to do that either. Update: I received a very helpful response from Arachnid. The solution I ended up with uses a metaclass. It is found below.
How to override HTTP request verb in GAE
257,094
2
1
1,104
0
python,google-app-engine,rest,metaclass
Thats Arachnid for your response. Pointing me to the source of the framework was really helpful. Last I looked the source wasn't there(there was only .pyc), maybe it changed with the new version of the SDK. For my situation I think overriding WSGIApplication would have been the right thing to do. However, I chose to use a metaclass instead, because it didn't require me to cargo-cult(copy) a bunch of the framework code into my code and then modifying it. This is my solution: class RequestHandlerMetaclass(type): def __init__(cls, name, bases, dct): super(RequestHandlerMetaclass, cls).__init__(name, bases, dct) org_post = getattr(cls, 'post') def post(self, *params, **kws): verb = self.request.get('_method') if verb: verb = verb.upper() if verb == 'DELETE': self.delete(*params, **kws) elif verb == 'PUT': self.put(*params, **kws) else: org_post(self, *params, **kws) setattr(cls, 'post', post) class MyRequestHandler(webapp.RequestHandler): __metaclass__ = RequestHandlerMetaclass
0
1
0
0
2008-10-31T22:37:00.000
2
0.197375
false
255,157
0
0
1
2
In the context of a Google App Engine Webapp framework application: I want to changed the request verb of a request in the case a parameter _method is provided, for example if a POST request comes in with a parameter _method=PUT, I need to change the request to call the put method of the handler. This is to cope with the way prototype.js works with verbs like PUT and DELETE(workaround for IE). Here is my first attempt: class MyRequestHandler(webapp.RequestHandler): def initialize(self, request, response): m = request.get('_method') if m: request.method = m.upper() webapp.RequestHandler.initialize(self, request, response) The problem is, for some reason whenever the redirect is done, the self.request.params are emptied by the time the handling method(put or delete) is called, even though they were populated when initialize was called. Anyone have a clue why this is? As a workaround I thought I could clone the params at initialize() time, but .copy() did not work, and I haven't found a way to do that either. Update: I received a very helpful response from Arachnid. The solution I ended up with uses a metaclass. It is found below.
Play audio with Python
22,689,253
-1
135
259,664
0
python,audio
If you're on OSX, you can use the "os" module or "subprocess" etc. to call the OSX "play" command. From the OSX shell, it looks like play "bah.wav" It starts to play in about a half-second on my machine.
0
1
0
1
2008-11-04T03:11:00.000
25
-0.008
false
260,738
0
0
0
1
How can I play audio (it would be like a 1 second sound) from a Python script? It would be best if it was platform independent, but firstly it needs to work on a Mac. I know I could just execute the afplay file.mp3 command from within Python, but is it possible to do it in raw Python? I would also be better if it didn't rely on external libraries.
How can I ask for root password but perform the action at a later time?
263,859
4
7
552
0
python,linux,ubuntu
Instead of chmod u+sing the shutdown command, allowing passwordless sudo access to that command would be better.. As for allowing shutdown at the end of the script, I suppose you could run the entire script with sudo, then drop privileges to the initial user at the start of the script?
0
1
0
0
2008-11-04T22:47:00.000
3
0.26052
false
263,773
0
0
0
3
I have a python script that I would like to add a "Shutdown when done" feature to. I know I can use gksudo (when the user clicks on "shutdown when done") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished). I have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that. Any ideas how I can achieve this? Thanks in advance, Ashy.
How can I ask for root password but perform the action at a later time?
263,851
1
7
552
0
python,linux,ubuntu
Escalate priority, spawn (fork (2)) a separate process that will wait (2), and drop priority in the main process.
0
1
0
0
2008-11-04T22:47:00.000
3
0.066568
false
263,773
0
0
0
3
I have a python script that I would like to add a "Shutdown when done" feature to. I know I can use gksudo (when the user clicks on "shutdown when done") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished). I have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that. Any ideas how I can achieve this? Thanks in advance, Ashy.
How can I ask for root password but perform the action at a later time?
263,804
3
7
552
0
python,linux,ubuntu
gksudo should have a timeout, I believe it's from the time you last executed a gksudo command. So I think I'd just throw out a "gksudo echo meh" or something every minute. Should reset the timer and keep you active until you reboot.
0
1
0
0
2008-11-04T22:47:00.000
3
1.2
true
263,773
0
0
0
3
I have a python script that I would like to add a "Shutdown when done" feature to. I know I can use gksudo (when the user clicks on "shutdown when done") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished). I have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that. Any ideas how I can achieve this? Thanks in advance, Ashy.
Python distutils and replacing strings in code
268,348
-1
2
283
0
python
"I often find a need to put paths in my code" -- this isn't very Pythonic to begin with. Ideally, your code lives in some place like site-packages and that's the end of that. Often, we have an installed "application" that uses a fairly fixed set of directories for working files. In linux, we get this information from environment variables and configuration files owned by the specific userid that's running the application. I don't think that you should be putting paths in your code. I think there's a better way. [I just wrote our app installation tool, which does create all the config files for a fairly complex app. I used the Mako templates tool to generate all four files from templates.]
0
1
0
0
2008-11-06T08:50:00.000
5
-0.039979
false
267,977
1
0
0
2
I often find a need to put paths in my code in order to find data or in some cases tool-specific modules. I've so far always used autotools because of this--it's just so easy to call sed to replace a few strings at build time. However, I'd like to find a more Pythonic way of doing this, i.e. use distutils or some other blessed way of building/installing. I've never managed to find anything relating to this in distutils documentation though so how do other people solve this problem?
Python distutils and replacing strings in code
348,082
0
2
283
0
python
The OP here, I've not finally managed to log in using my OpenID. @S.Lott Point well taken, but for some Linux distros it seems to be standard to install application-specific data and application-specific modules in specific locations. I think that making these locations configurable at build/install time is a nice thing to do for people packaging my application. AFAICS “the pythonic way” in this case would force these packagers to apply patches to my code. I'm also in the habit of writing applications where the executable part is a tiny wrapper around a main function in an application-specific module. To me it doesn't seem right to stick this application-specific module in /usr/lib/python2.5/site-packages.
0
1
0
0
2008-11-06T08:50:00.000
5
0
false
267,977
1
0
0
2
I often find a need to put paths in my code in order to find data or in some cases tool-specific modules. I've so far always used autotools because of this--it's just so easy to call sed to replace a few strings at build time. However, I'd like to find a more Pythonic way of doing this, i.e. use distutils or some other blessed way of building/installing. I've never managed to find anything relating to this in distutils documentation though so how do other people solve this problem?
How do I find the location of Python module sources?
269,814
1
564
717,501
0
python,module
Not all python modules are written in python. Datetime happens to be one of them that is not, and (on linux) is datetime.so. You would have to download the source code to the python standard library to get at it.
0
1
0
0
2008-11-06T18:36:00.000
20
0.01
false
269,795
1
0
0
5
How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux? I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well.
How do I find the location of Python module sources?
32,784,452
103
564
717,501
0
python,module
If you're using pip to install your modules, just pip show $module the location is returned.
0
1
0
0
2008-11-06T18:36:00.000
20
1
false
269,795
1
0
0
5
How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux? I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well.
How do I find the location of Python module sources?
27,230,006
1
564
717,501
0
python,module
For those who prefer a GUI solution: if you're using a gui such as Spyder (part of the Anaconda installation) you can just right-click the module name (such as "csv" in "import csv") and select "go to definition" - this will open the file, but also on the top you can see the exact file location ("C:....csv.py")
0
1
0
0
2008-11-06T18:36:00.000
20
0.01
false
269,795
1
0
0
5
How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux? I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well.
How do I find the location of Python module sources?
72,396,307
-1
564
717,501
0
python,module
as written above in python just use help(module) ie import fractions help(fractions) if your module, in the example fractions, is installed then it will tell you location and info about it, if its not installed it says module not available if its not available it doesn't come by default with python in which case you can check where you found it for download info
0
1
0
0
2008-11-06T18:36:00.000
20
-0.01
false
269,795
1
0
0
5
How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux? I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well.
How do I find the location of Python module sources?
61,095,592
5
564
717,501
0
python,module
Another way to check if you have multiple python versions installed, from the terminal. $ python3 -m pip show pyperclip Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site- $ python -m pip show pyperclip Location: /Users/umeshvuyyuru/Library/Python/2.7/lib/python/site-packages
0
1
0
0
2008-11-06T18:36:00.000
20
0.049958
false
269,795
1
0
0
5
How do I learn where the source file for a given Python module is installed? Is the method different on Windows than on Linux? I'm trying to look for the source of the datetime module in particular, but I'm interested in a more general answer as well.
Interactive console using Pydev in Eclipse?
1,116,728
0
36
27,430
0
python,debugging,console,pydev,interactive
When I set a break point and hit F11 Eclipse launches the debugger and prompts to open the "Debug Perspective". You can then open the Window-->Show View --> Expressions which opens the expressions view, you can then right click in the Expressions view windows and choose "Add Watch Expression" to add any expression(such as dir) Conversely I was also able to type in dir(some expression) in the PyDev console and get the same effect. I'm using PyDev 1.4.6.2788
0
1
0
0
2008-11-07T09:34:00.000
5
0
false
271,625
1
0
0
3
I'm debugging my Python code in Eclipse using the Pydev plugin. I'm able to open a Pydev console and it gives me two options: "Console for currently active editor" and "Python console". However none of them is useful to inspect current variable status after a breakpoint. For example, the code stopped at a breakpoint and I want to inspect an "action" variable using the console. However my variables are not available. How can I do things like "dir(action)", etc? (even if it is not using a console).
Interactive console using Pydev in Eclipse?
31,548,800
0
36
27,430
0
python,debugging,console,pydev,interactive
On a small monitor, you may not realize that the debug interactive console is different from the regular interactive console: it has a second command prompt at the bottom where you type, not at the top like the normal console.
0
1
0
0
2008-11-07T09:34:00.000
5
0
false
271,625
1
0
0
3
I'm debugging my Python code in Eclipse using the Pydev plugin. I'm able to open a Pydev console and it gives me two options: "Console for currently active editor" and "Python console". However none of them is useful to inspect current variable status after a breakpoint. For example, the code stopped at a breakpoint and I want to inspect an "action" variable using the console. However my variables are not available. How can I do things like "dir(action)", etc? (even if it is not using a console).
Interactive console using Pydev in Eclipse?
271,692
1
36
27,430
0
python,debugging,console,pydev,interactive
Double click on "action" or any other variable. ctrl+shift+D And if you're using watches, I cant imagine better interaction. You are able to see every change.
0
1
0
0
2008-11-07T09:34:00.000
5
0.039979
false
271,625
1
0
0
3
I'm debugging my Python code in Eclipse using the Pydev plugin. I'm able to open a Pydev console and it gives me two options: "Console for currently active editor" and "Python console". However none of them is useful to inspect current variable status after a breakpoint. For example, the code stopped at a breakpoint and I want to inspect an "action" variable using the console. However my variables are not available. How can I do things like "dir(action)", etc? (even if it is not using a console).
Python memory debugging with GDB
273,204
0
4
4,500
0
python,linux,debugging,openssl
If you're using CDLL to wrap a C library in python, and this is 64-bit linux, there's a good chance that you're CDLL wrapper is misconfigured. CDLL defaults to int return types on all platforms (should be a long long on 64-bit systems) and just expects you to pass the right arguments in. You may need to verify the CDLL wrapper in this case...
0
1
0
0
2008-11-07T18:13:00.000
4
0
false
273,043
1
0
0
1
We have a Linux application that makes use of OpenSSL's Python bindings and I suspect it is causing random crashes. Occasionally, we see it crash with the message: Python Fatal Error: GC Object already tracked which would appear to be either a programming error on the part of the library, or a symptom of memory corruption. Is there any way to know the last line of Python source code it executed, given a core file? Or if it is attached in GDB? I realize it is probably all compiled bytecode, but I'm hoping there someone out there may have dealt with this. Currently it is running with the trace module active and we're hoping it will happen again, but it could be a long while.
Python: How do I generate a keypress?
279,627
0
1
2,607
0
python,keypress,popen
What platform is this on? You may have to actually feed events into the event loop, if it's running on Win32.
0
1
0
1
2008-11-10T22:41:00.000
3
0
false
279,434
0
0
0
2
I am opening a process (with os.popen() ) that, for some commands, detects certain keypresses (e.g. ESC - not the character, the key). Is there a way to send keypress events to the process?
Python: How do I generate a keypress?
279,460
0
1
2,607
0
python,keypress,popen
The obvious way would be to start the process in it's own shell. something like os.popen("sh command")
0
1
0
1
2008-11-10T22:41:00.000
3
0
false
279,434
0
0
0
2
I am opening a process (with os.popen() ) that, for some commands, detects certain keypresses (e.g. ESC - not the character, the key). Is there a way to send keypress events to the process?
How can I download python .egg files, when behind a firewall
282,939
1
1
1,615
0
python,windows,linux,cygwin,turbogears
Add python to the firewall exceptions list. Just make sure you don't run any questionable code made in python, of course.
0
1
0
0
2008-11-12T03:15:00.000
5
0.039979
false
282,907
1
0
0
2
I'm going to try out turbogears however I'm on windows vista. however due to firewall proxy problems, it seems i can't download .egg files which is required for setup turbogears to get installed in my windows environment. I do have a bootable, or I can make a bootable Linux USB, I can try cygwin but I am not sure where to start with cygwin, so I was wondering what would solve my firewall / proxy problem of installing something like turbogears. if it's possible, is there some non-online version of turbogears that i could just download from visiting a site and then somehow importing that non-online version into my python environment? thanks so much!:)
How can I download python .egg files, when behind a firewall
283,271
2
1
1,615
0
python,windows,linux,cygwin,turbogears
You could use the old firewall hack... try throwing "?file.jpg" or "#file.jpg" on the end (sans quotes). The firewall may see this as you're trying to download an image file which it'll allow, the responding server probably won't care that you've attached a query string, and (I think) python will just see an egg.
0
1
0
0
2008-11-12T03:15:00.000
5
0.07983
false
282,907
1
0
0
2
I'm going to try out turbogears however I'm on windows vista. however due to firewall proxy problems, it seems i can't download .egg files which is required for setup turbogears to get installed in my windows environment. I do have a bootable, or I can make a bootable Linux USB, I can try cygwin but I am not sure where to start with cygwin, so I was wondering what would solve my firewall / proxy problem of installing something like turbogears. if it's possible, is there some non-online version of turbogears that i could just download from visiting a site and then somehow importing that non-online version into my python environment? thanks so much!:)
Why would an "command not recognized" error occur only when a window is populated?
286,436
0
1
1,123
0
python,windows
The suggested answer seems to have fixed the problem. I also realized that I needed to use os.name to determine which OS is being used, then I can use the correct path format for loading the external Python file.
0
1
0
0
2008-11-12T09:38:00.000
2
0
false
283,431
0
0
0
1
My record sheet app has a menu option for creating a new, blank record sheet. When I open a sheet window, I can open new windows without a problem, using subprocess.Popen() to do it. However, under Windows (I haven't tested it on other OSes yet), if I open a new window then use the "open file" dialog to populate the fields with data from a file, I'm no longer able to create new windows. Once it's populated, Windows gives me the 'foo.py' is not recognized as an internal or external command, operable program or batch file. I don't understand what would cause Windows to suddenly not recognize the Popen() call. I don't have any code that would affect it in any way that I'm aware of.
Search directory in SVN for files with specific file extension and copy to another folder?
291,477
2
2
1,000
0
python,svn,file
I think it is easiest to check out (or, better, export) the source tree using the svn command line utility: you can use os.system to invoke it. There are also direct Python-to-svn API bindings, but I would advise against using them if you are new to Python. You can then traverse the checkout folder, e.g. using os.walk; the copying itself can be done with shutil.copy.
0
1
0
1
2008-11-14T21:16:00.000
1
1.2
true
291,467
0
0
0
1
I would like my python script to search through a directory in SVN, locate the files ending with a particular extension (eg. *.exe), and copy these files to a directory that has been created in my C drive. How can I do this? I'm new to Python so a detailed response and/or point in the right direction would be very much appreciated. Follow-up: When using os.walk what parameter would I pass in to ensure that I'm copying files with a specific extension (eg. *.exe)?
How do I find userid by login (Python under *NIX)
294,535
5
12
4,216
0
python,linux,unix,process-management
Never directly scan /etc/passwd. For instance, on a Linux system I administer, the user accounts are not on /etc/passwd, but on a LDAP server. The correct way is to use getpwent/getgrent and related C functions (as in @TFKyle's answer), which will get the information on the correct way for each system (on Linux glibc, it reads /etc/nsswitch.conf to know which NSS dynamic libraries to load to get the information).
0
1
0
1
2008-11-16T22:11:00.000
2
0.462117
false
294,470
0
0
0
1
I need to set my process to run under 'nobody', I've found os.setuid(), but how do I find uid if I have login? I've found out that uids are in /etc/passwd, but maybe there is a more pythonic way than scanning /etc/passwd. Anybody?
Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?
628,329
8
70
64,229
0
java,python,performance,protocol-buffers,thrift
I did test performance of PB with number of other data formats (xml, json, default object serialization, hessian, one proprietary one) and libraries (jaxb, fast infoset, hand-written) for data binding task (both reading and writing), but thrift's format(s) was not included. Performance for formats with multiple converters (like xml) had very high variance, from very slow to pretty-darn-fast. Correlation between claims of authors and perceived performance was rather weak. Especially so for packages that made wildest claims. For what it is worth, I found PB performance to be bit over hyped (usually not by its authors, but others who only know who wrote it). With default settings it did not beat fastest textual xml alternative. With optimized mode (why is this not default?), it was bit faster, comparable with the fastest JSON package. Hessian was rather fast, textual json also. Properietary binary format (no name here, it was company internal) was the slowest. Java object serialization was fast for larger messages, less so for small objects (i.e. high fixed per-operation noverhead). With PB message size was compact, but given all trade-offs you have to do (data is not self-descriptive: if you lose the schema, you lose data; there are indexes of course, and value types, but from what you have reverse-engineer back to field names if you want), I personally would only choose it for specific use cases -- size-sensitive, closely coupled system where interface/format never (or very very rarely) changes. My opinion in this is that (a) implementation often matters more than specification (of data format), (b) end-to-end, differences between best-of-breed (for different formats) are usually not big enough to dictate the choice. That is, you may be better off choosing format+API/lib/framework you like using most (or has best tool support), find best implementation, and see if that works fast enough. If (and only if!) not, consider next best alternative. ps. Not sure what EJB3 here would be. Maybe just plain of Java serialization?
0
1
0
1
2008-11-17T19:48:00.000
8
1
false
296,650
0
0
0
3
We're looking into transport/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this: Has anyone done server performance tests for simple echo services as well as serialization/deserialization for various messages sizes comparing EJB3, Thrift, and Protocol Buffers on Linux? Primarily languages will be Java, C/C++, Python, and PHP. Update: I'm still very interested in this, if anyone has done any further benchmarks please let me know. Also, very interesting benchmark showing compressed JSON performing similar / better than Thrift / Protocol Buffers, so I'm throwing JSON into this question as well.
Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?
297,193
5
70
64,229
0
java,python,performance,protocol-buffers,thrift
If the raw net performance is the target, then nothing beats IIOP (see RMI/IIOP). Smallest possible footprint -- only binary data, no markup at all. Serialization/deserialization is very fast too. Since it's IIOP (that is CORBA), almost all languages have bindings. But I presume the performance is not the only requirement, right?
0
1
0
1
2008-11-17T19:48:00.000
8
0.124353
false
296,650
0
0
0
3
We're looking into transport/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this: Has anyone done server performance tests for simple echo services as well as serialization/deserialization for various messages sizes comparing EJB3, Thrift, and Protocol Buffers on Linux? Primarily languages will be Java, C/C++, Python, and PHP. Update: I'm still very interested in this, if anyone has done any further benchmarks please let me know. Also, very interesting benchmark showing compressed JSON performing similar / better than Thrift / Protocol Buffers, so I'm throwing JSON into this question as well.
Performance comparison of Thrift, Protocol Buffers, JSON, EJB, other?
296,677
4
70
64,229
0
java,python,performance,protocol-buffers,thrift
One of the things near the top of my "to-do" list for PBs is to port Google's internal Protocol Buffer performance benchmark - it's mostly a case of taking confidential message formats and turning them into entirely bland ones, and then doing the same for the data. When that's been done, I'd imagine you could build the same messages in Thrift and then compare the performance. In other words, I don't have the data for you yet - but hopefully in the next couple of weeks...
0
1
0
1
2008-11-17T19:48:00.000
8
0.099668
false
296,650
0
0
0
3
We're looking into transport/protocol solutions and were about to do various performance tests, so I thought I'd check with the community if they've already done this: Has anyone done server performance tests for simple echo services as well as serialization/deserialization for various messages sizes comparing EJB3, Thrift, and Protocol Buffers on Linux? Primarily languages will be Java, C/C++, Python, and PHP. Update: I'm still very interested in this, if anyone has done any further benchmarks please let me know. Also, very interesting benchmark showing compressed JSON performing similar / better than Thrift / Protocol Buffers, so I'm throwing JSON into this question as well.
python (jython) archiving library
298,027
1
1
256
0
java,python,jython,archive
You can use java.util.zip, when I was using Jython the built in zip library in python didn't work
0
1
0
0
2008-11-18T06:32:00.000
2
0.099668
false
298,004
1
0
1
1
Is there a neat archiving library that automatically handles archiving a folder or directories for you out there? I am using Jython, so Java libs are also open for use. -UPDATE- Also Im looking for timestamp archiving. ie archive-dir/2008/11/16/zipfilebypreference.zip then the next day call it again and it creates another folder. Im sure there is something out there on the internet, who knows?
How can I get my python (version 2.5) script to run a jar file inside a folder instead of from command line?
299,262
1
5
8,648
0
python
In general: Use os.chdir to change the directory of the parent process, then os.system to run the jar file. If you need to keep Python's working directory stable, you need to chdir back to original working directory - you need to record that with os.getcwd(). On Unix: Create a child process with os.fork explicitly. In the parent, wait for the child with os.waitpid. In the child, use os.chdir, then os.exec to run java.
0
1
0
1
2008-11-18T16:22:00.000
2
0.099668
false
299,249
0
0
0
1
I am familiar with using the os.system to run from the command line. However, I would like to be able to run a jar file from inside of a specific folder, eg. my 'test' folder. This is because my jar (located in my 'test' folder) requires a file inside of my 'test' folder. So, how would I write a function in my script that does the following: c:\test>java -jar run_this.jar required_parameter.ext ? I'm a python newbie so details are greatly appreciated. Thanks in advance.
Global hotkey for Python application in Gnome
302,168
2
6
1,770
0
python,gnome
Check out the Deskbar source code - they do this; afaik, they call out a C library that interacts with X11 to do the job
0
1
0
0
2008-11-19T15:08:00.000
2
1.2
true
302,163
0
0
0
1
I would like to assign a global hotkey to my Python application, running in Gnome. How do I do that? All I can find are two year old posts saying, well, pretty much nothing :-)
How do I remove/delete a folder that is not empty?
55,308,643
1
1,021
854,907
0
python,file
For Windows, if directory is not empty, and you have read-only files or you get errors like Access is denied The process cannot access the file because it is being used by another process Try this, os.system('rmdir /S /Q "{}"'.format(directory)) It's equivalent for rm -rf in Linux/Mac.
0
1
0
0
2008-11-19T20:15:00.000
20
0.01
false
303,200
0
0
0
1
I am getting an 'access is denied' error when I attempt to delete a folder that is not empty. I used the following command in my attempt: os.remove("/folder_name"). What is the most effective way of removing/deleting a folder/directory that is not empty?
What do I use on linux to make a python program executable
48,661,346
4
105
222,482
0
python,linux,file-permissions
If one want to make executable hello.py first find the path where python is in your os with : which python it usually resides under "/usr/bin/python" folder. at the very first line of hello.py one should add : #!/usr/bin/python then through linux command chmod one should just make it executable like : chmod +x hello.py and execute with ./hello.py
0
1
0
0
2008-11-20T10:27:00.000
8
0.099668
false
304,883
0
0
0
2
I just installed a linux system (Kubuntu) and was wondering if there is a program to make python programs executable for linux.
What do I use on linux to make a python program executable
56,267,080
1
105
222,482
0
python,linux,file-permissions
I do the following: put #! /usr/bin/env python3 at top of script chmod u+x file.py Change .py to .command in file name This essentially turns the file into a bash executable. When you double-click it, it should run. This works in Unix-based systems.
0
1
0
0
2008-11-20T10:27:00.000
8
0.024995
false
304,883
0
0
0
2
I just installed a linux system (Kubuntu) and was wondering if there is a program to make python programs executable for linux.
Appropriate location for my application's cache on Windows
305,679
0
3
955
0
python,windows
Does the app have any preferences, settings or options that the user can specify? If so, add an option where the user can specify the location of the data, with a default of the current Windows temp directory. There's always a chance they may not have enough space on the drive with the temp directory, and would need to use a different drive/directory.
0
1
0
0
2008-11-20T15:28:00.000
7
0
false
305,647
1
0
0
1
My application caches some data on disk. Because the cache may be large, it should not be stored on a network drive. It should persist between invocations of the application. I have a mechanism for the user to choose a location, but would like the default to be sensible and "the right thing" for the platform. What is the appropriate location for such a cache? Is there an API for determining the appropriate location? How do I call it from Python?
How can I get a list of the running applications with GTK?
306,866
0
2
368
0
python,gtk,pygtk
The panel you are referring to is the GNOME panel. So this is a GNOME question, not a GTK question. There is not a well-defined concept of "multi-window application" in GNOME that I know of. The panel task list is probably build by querying the window manager for the list of windows and grouping the windows by their "class" property. There are also various window manager hints that must be taken into account, for example to ignore panels and other utility windows. In your place, I would look at the source code of the taskbar applet. There is maybe some documentation somewhere that covers the status-quo, but I do know where it would be.
1
1
0
0
2008-11-20T19:02:00.000
2
0
false
306,456
0
0
0
2
How can I get a list of the running applications? I'm referring to the ones in the panel at the bottom of the screen.
How can I get a list of the running applications with GTK?
307,046
3
2
368
0
python,gtk,pygtk
I believe what you are looking for is libwnck
1
1
0
0
2008-11-20T19:02:00.000
2
1.2
true
306,456
0
0
0
2
How can I get a list of the running applications? I'm referring to the ones in the panel at the bottom of the screen.
Python - Setting / Getting Environment Variables and Addrs
310,299
4
1
10,481
0
python,linux,environment-variables
For accessing and setting environment variables, read up on the os.environ dictionary. You can also use os.putenv to set an environment variable.
0
1
0
0
2008-11-21T20:37:00.000
3
0.26052
false
310,118
1
0
0
2
I need to set an environment variable in Python and find the address in memory where it is located. Since it's on Linux, I don't mind about using libraries that only work consistently on Linux (if that's the only way). How would you do this? Edit: The scope of the problem is as follows: I'm trying to hack a program for class, and essentially I'm putting my shellcode into an environment variable and then overwriting one byte on the victim code with the address of my environment variable. I need to find a way to automate this in Python, so my question is two-fold: Is there a way to get the address in memory of an environment variable? Can this only be done in bash/C or can I do it purely in Python?
Python - Setting / Getting Environment Variables and Addrs
310,717
0
1
10,481
0
python,linux,environment-variables
Pass the address itself in an environment variable, and just read it with os.getenv().
0
1
0
0
2008-11-21T20:37:00.000
3
0
false
310,118
1
0
0
2
I need to set an environment variable in Python and find the address in memory where it is located. Since it's on Linux, I don't mind about using libraries that only work consistently on Linux (if that's the only way). How would you do this? Edit: The scope of the problem is as follows: I'm trying to hack a program for class, and essentially I'm putting my shellcode into an environment variable and then overwriting one byte on the victim code with the address of my environment variable. I need to find a way to automate this in Python, so my question is two-fold: Is there a way to get the address in memory of an environment variable? Can this only be done in bash/C or can I do it purely in Python?
Python as FastCGI under windows and apache
318,517
2
6
3,212
0
python,windows,apache,fastcgi
You might find it easier to ditch FastCGI altogether and just run a python webserver on a localhost port. Then just use mod_rewrite to map the apache urls to the internal webserver. (I started offering FastCGI at my hosting company and to my surprise, nearly everyone ditched it in favor of just running their own web server on the ports I provided them.)
0
1
1
0
2008-11-23T20:39:00.000
3
0.132549
false
312,928
0
0
0
1
I need to run a simple request/response python module under an existing system with windows/apache/FastCGI. All the FastCGI wrappers for python I tried work for Linux only (they use socket.fromfd() and other such shticks). Is there a wrapper that runs under windows?
Running a function periodically in twisted protocol
315,855
3
24
8,021
0
python,tcp,twisted,protocols
I'd imagine the easiest way to do that is to manage a list of clients in the protocol with connectionMade and connectionLost in the client and then use a LoopingCall to ask each client to send data. That feels a little invasive, but I don't think you'd want to do it without the protocol having some control over the transmission/reception. Of course, I'd have to see your code to really know how it'd fit in well. Got a github link? :)
0
1
0
0
2008-11-24T22:21:00.000
2
0.291313
false
315,716
0
0
0
1
I am looking for a way to periodically send some data over all clients connected to a TCP port. I am looking at twisted python and I am aware of reactor.callLater. But how do I use it to send some data to all connected clients periodically ? The data sending logic is in Protocol class and it is instantiated by the reactor as needed. I don't know how to tie it from reactor to all protocol instances...
Ghostscript PDF -> TIFF throws an untrappable exception, when consuming files with asian fonts
317,300
1
0
416
0
python,jython,tiff,ghostscript
It may be that you need to read stderr from the child process.
0
1
0
1
2008-11-25T06:41:00.000
1
0.197375
false
316,518
0
0
0
1
Ghostscript curls up and dies, throwing an exception to stdout which I cannot catch and log. I am pretty sure it gets sick when I give it asian fonts. Has anybody backed into this problem and solved it?
Ensuring subprocesses are dead on exiting Python program
320,251
3
77
78,382
0
python,subprocess,kill,zombie-process
poll( ) Check if child process has terminated. Returns returncode attribute.
0
1
0
0
2008-11-26T10:21:00.000
15
0.039979
false
320,232
1
0
0
1
Is there a way to ensure all created subprocess are dead at exit time of a Python program? By subprocess I mean those created with subprocess.Popen(). If not, should I iterate over all of the issuing kills and then kills -9? anything cleaner?
Scripting language choice for initial performance
328,062
3
10
8,004
0
python,ruby,perl,bash,scripting-language
If Low memory and low startup time are truly important you might want to consider doing the work to keep the C code cross platform, however I have found this is rarely necessary. Personally I would use Ruby or Python for this type of job, they both make it very easy to make clear understandable code that others can maintain (or you can maintain after not looking at it for 6 months). If you have the control to do so I would also suggest getting the latest version of the interpreter, as both Ruby and Python have made notable improvements around performance recently. It is a bit of a personal thing. Programming Ruby makes me happy, C code does not (nor bash scripting for anything non-trivial).
0
1
0
1
2008-11-29T21:34:00.000
13
0.046121
false
328,041
0
0
0
9
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some. Startup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important. So basically I'm looking for the best scripting languages that is: Cross platform. Capable of XML parsing and HTTP Posts. Low memory and low startup time. Possible choices include but are not limited to: bash/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?
Scripting language choice for initial performance
328,075
0
10
8,004
0
python,ruby,perl,bash,scripting-language
I agree with others in that you should probably try to make this a more portable C app instead of porting it over to something else since any scripting language is going to introduce significant overhead from a startup perspective, have a much larger memory footprint, and will probably be much slower. In my experience, Python is the most efficient of the three, followed by Perl and then Ruby with the difference between Perl and Ruby being particularly large in certain areas. If you really want to try porting this to a scripting language, I would put together a prototype in the language you are most comfortable with and see if it comes close to your requirements. If you don't have a preference, start with Python as it is easy to learn and use and if it is too slow with Python, Perl and Ruby probably won't be able to do any better.
0
1
0
1
2008-11-29T21:34:00.000
13
0
false
328,041
0
0
0
9
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some. Startup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important. So basically I'm looking for the best scripting languages that is: Cross platform. Capable of XML parsing and HTTP Posts. Low memory and low startup time. Possible choices include but are not limited to: bash/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?
Scripting language choice for initial performance
328,054
5
10
8,004
0
python,ruby,perl,bash,scripting-language
When written properly, C should be platform independant and would only need a recompile for those different platforms. You might have to jump through some #ifdef hoops for the headers (not all systems use the same headers), but most normal (non-win32 API) calls are very portable. For web access (which I presume you need as you mention bash+curl), you could take a look at libcurl, it's available for all the platforms you mentioned, and shouldn't be that hard to work with. With execution time and memory cost in mind, I doubt you could go any faster than properly written C with any scripting language as you would lose at least some time on interpreting the script...
0
1
0
1
2008-11-29T21:34:00.000
13
0.076772
false
328,041
0
0
0
9
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some. Startup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important. So basically I'm looking for the best scripting languages that is: Cross platform. Capable of XML parsing and HTTP Posts. Low memory and low startup time. Possible choices include but are not limited to: bash/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?
Scripting language choice for initial performance
328,120
4
10
8,004
0
python,ruby,perl,bash,scripting-language
I concur with Lua: it is super-portable, it has XML libraries, either native or by binding C libraries like Expat, it has a good socket library (LuaSocket) plus, for complex stuff, some cURL bindings, and is well known for being very lightweight (often embedded in low memory devices), very fast (one of the fastest scripting languages), and powerful. And very easy to code! It is coded in pure Ansi C, and lot of people claim it has one of the best C biding API (calling C routines from Lua, calling Lua code from C...).
0
1
0
1
2008-11-29T21:34:00.000
13
0.061461
false
328,041
0
0
0
9
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some. Startup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important. So basically I'm looking for the best scripting languages that is: Cross platform. Capable of XML parsing and HTTP Posts. Low memory and low startup time. Possible choices include but are not limited to: bash/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?
Scripting language choice for initial performance
328,065
9
10
8,004
0
python,ruby,perl,bash,scripting-language
Because of your requirement for fast startup time and a calling frequency greater than 1Hz I'd recommend either staying with C and figuring out how to make it portable (not always as easy as a few ifdefs) or exploring the possibility of turning it into a service daemon that is always running. Of course this depends on how Python can have lower startup times if you compile the module and run the .pyc file, but it is still generally considered slow. Perl, in my experience, in the fastest of the scripting languages so you might have good luck with a perl daemon. You could also look at cross platform frameworks like gtk, wxWidgets and Qt. While they are targeted at GUIs they do have low level cross platform data types and network libraries that could make the job of using a fast C based application easier.
0
1
0
1
2008-11-29T21:34:00.000
13
1.2
true
328,041
0
0
0
9
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some. Startup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important. So basically I'm looking for the best scripting languages that is: Cross platform. Capable of XML parsing and HTTP Posts. Low memory and low startup time. Possible choices include but are not limited to: bash/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?
Scripting language choice for initial performance
328,045
23
10
8,004
0
python,ruby,perl,bash,scripting-language
Lua is a scripting language that meets your criteria. It's certainly the fastest and lowest memory scripting language available.
0
1
0
1
2008-11-29T21:34:00.000
13
1
false
328,041
0
0
0
9
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some. Startup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important. So basically I'm looking for the best scripting languages that is: Cross platform. Capable of XML parsing and HTTP Posts. Low memory and low startup time. Possible choices include but are not limited to: bash/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?
Scripting language choice for initial performance
328,519
0
10
8,004
0
python,ruby,perl,bash,scripting-language
Port your app to Ruby. If your app is too slow, profile it and rewrite the those parts in C.
0
1
0
1
2008-11-29T21:34:00.000
13
0
false
328,041
0
0
0
9
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some. Startup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important. So basically I'm looking for the best scripting languages that is: Cross platform. Capable of XML parsing and HTTP Posts. Low memory and low startup time. Possible choices include but are not limited to: bash/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?
Scripting language choice for initial performance
328,129
6
10
8,004
0
python,ruby,perl,bash,scripting-language
"called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important." This doesn't sound like a script to me at all. This sounds like a server handling requests that arrive from every minute to several times a second. If it's a server, handling requests, start-up time doesn't mean as much as responsiveness. In which case, Python might work out well, and still keep performance up. Rather than restarting, you're just processing another request. You get to keep as much state as you need to optimize performance.
0
1
0
1
2008-11-29T21:34:00.000
13
1
false
328,041
0
0
0
9
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some. Startup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important. So basically I'm looking for the best scripting languages that is: Cross platform. Capable of XML parsing and HTTP Posts. Low memory and low startup time. Possible choices include but are not limited to: bash/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?
Scripting language choice for initial performance
328,132
0
10
8,004
0
python,ruby,perl,bash,scripting-language
Can you instead have it be a long-running process and answer http or rpc requests? This would satisfy the latency requirements in almost any scenario, but I don't know if that would break your memory footprint constraints.
0
1
0
1
2008-11-29T21:34:00.000
13
0
false
328,041
0
0
0
9
I have a small lightweight application that is used as part of a larger solution. Currently it is written in C but I am looking to rewrite it using a cross-platform scripting language. The solution needs to run on Windows, Linux, Solaris, AIX and HP-UX. The existing C application works fine but I want to have a single script I can maintain for all platforms. At the same time, I do not want to lose a lot of performance but am willing to lose some. Startup cost of the script is very important. This script can be called anywhere from every minute to many times per second. As a consequence, keeping it's memory and startup time low are important. So basically I'm looking for the best scripting languages that is: Cross platform. Capable of XML parsing and HTTP Posts. Low memory and low startup time. Possible choices include but are not limited to: bash/ksh + curl, Perl, Python and Ruby. What would you recommend for this type of a scenario?
How to pack python libs I'm using so I can distribute them with my app and have as few dependencies as possible
331,703
2
4
505
0
python,linux,deployment
But if you make a deb with the correct dependencies listed the installer will download them for the user. That's the best way, as it's non redundant. Maybe you could make a tar or zip with your deb and all the third-party deb's and an install script that just install all the debs in the correct order. This way, if the user already has some package it wouldn't be installed again.
0
1
0
0
2008-12-01T16:40:00.000
4
0.099668
false
331,377
1
0
0
1
How to pack python libs I'm using so I can distribute them with my app and have as few dependencies as possible and also not to conflict with different lib/version that is already on my system. L.E.: Sorry i forgot to specify. I will be doing this on linux. And I'm not referring in making my app a installable file like deb/rpm, etc but how to organize my files so like for example I'll be using cherrypy and sqlalchemy I'll ship those with my app and not put the user through the pain of installing all the dependencies by himself.
Python subprocess.call() fails when using pythonw.exe
337,990
7
5
6,198
0
python,multithreading,subprocess
sys.stdin and sys.stdout handles are invalid because pythonw does not provide console support as it runs as a deamon, so default arguments of subprocess.call() are failing. Deamon programs close stdin/stdout/stderr purposedly and use logging instead, so that you have to manage this yourself: I would suggest to use subprocess.PIPE. If you really don't care about what the sub process says for errors and all, you could use os.devnull (I'm not really sure how portable it is?) but I wouldn't recommend that.
0
1
0
0
2008-12-03T16:54:00.000
3
1.2
true
337,870
1
0
0
2
I have some Python code that works correctly when I use python.exe to run it, but fails if I use pythonw.exe. def runStuff(commandLine): outputFileName = 'somefile.txt' outputFile = open(outputFileName, "w") try: result = subprocess.call(commandLine, shell=True, stdout=outputFile) except: print 'Exception thrown:', str(sys.exc_info()[1]) myThread = threading.Thread(None, target=runStuff, commandLine=['whatever...']) myThread.start() The message I get is: Exception thrown: [Error 6] The handle is invalid However, if I don't specify the 'stdout' parameter, subprocess.call() starts okay. I can see that pythonw.exe might be redirecting output itself, but I can't see why I'm blocked from specifying stdout for a new thread.
Python subprocess.call() fails when using pythonw.exe
25,453,133
2
5
6,198
0
python,multithreading,subprocess
This is an old question, but the same problem happened with pyInstaller too. In the truth, this will happen with any framework that converts code in python for exe without console. In my tests, I observed that if I use the flag "console=True" into my spec file (pyInstaller) the error no longer occurs. . The solution was follow the tip of Piotr Lesnicki.
0
1
0
0
2008-12-03T16:54:00.000
3
0.132549
false
337,870
1
0
0
2
I have some Python code that works correctly when I use python.exe to run it, but fails if I use pythonw.exe. def runStuff(commandLine): outputFileName = 'somefile.txt' outputFile = open(outputFileName, "w") try: result = subprocess.call(commandLine, shell=True, stdout=outputFile) except: print 'Exception thrown:', str(sys.exc_info()[1]) myThread = threading.Thread(None, target=runStuff, commandLine=['whatever...']) myThread.start() The message I get is: Exception thrown: [Error 6] The handle is invalid However, if I don't specify the 'stdout' parameter, subprocess.call() starts okay. I can see that pythonw.exe might be redirecting output itself, but I can't see why I'm blocked from specifying stdout for a new thread.
How can I reboot a Windows XP64 Machine in a Python Script?
341,369
4
4
521
0
python,windows
found it win32api.InitiateSystemShutdown("localhost", "Maintenance Reboot", 60, 1, 1)
0
1
0
0
2008-12-04T16:06:00.000
2
1.2
true
341,138
1
0
0
1
How can I reboot a Windows XP64 Machine in a Python Script? This machine does not have the "shutdown" or "restart" executables available.
Can I install Python 3.x and 2.x on the same Windows computer?
341,231
1
176
244,252
0
python,windows,python-3.x,compatibility
I think there is an option to setup the windows file association for .py files in the installer. Uncheck it and you should be fine. If not, you can easily re-associate .py files with the previous version. The simplest way is to right click on a .py file, select "open with" / "choose program". On the dialog that appears, select or browse to the version of python you want to use by default, and check the "always use this program to open this kind of file" checkbox.
0
1
0
0
2008-12-04T16:18:00.000
20
0.01
false
341,184
1
0
0
5
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
Can I install Python 3.x and 2.x on the same Windows computer?
341,444
0
176
244,252
0
python,windows,python-3.x,compatibility
I would assume so, I have Python 2.4, 2.5 and 2.6 installed side-by-side on the same computer.
0
1
0
0
2008-12-04T16:18:00.000
20
0
false
341,184
1
0
0
5
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
Can I install Python 3.x and 2.x on the same Windows computer?
453,580
1
176
244,252
0
python,windows,python-3.x,compatibility
You should make sure that the PATH environment variable doesn't contain both python.exe files ( add the one you're currently using to run scripts on a day to day basis ) , or do as Kniht suggested with the batch files . Aside from that , I don't see why not . P.S : I have 2.6 installed as my "primary" python and 3.0 as my "play" python . The 2.6 is included in the PATH . Everything works fine .
0
1
0
0
2008-12-04T16:18:00.000
20
0.01
false
341,184
1
0
0
5
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
Can I install Python 3.x and 2.x on the same Windows computer?
341,216
4
176
244,252
0
python,windows,python-3.x,compatibility
As far as I know Python runs off of the commandline using the PATH variable as opposed to a registry setting. So if you point to the correct version on your PATH you will use that. Remember to restart your command prompt to use the new PATH settings.
0
1
0
0
2008-12-04T16:18:00.000
20
0.039979
false
341,184
1
0
0
5
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
Can I install Python 3.x and 2.x on the same Windows computer?
42,079,860
0
176
244,252
0
python,windows,python-3.x,compatibility
I am just starting out with python now. I'm reading Zed Shaw's book "Learn Python the Hard Way" which requires python version 2.x but am also taking a class that requires python 3.x So here is what I did. Download python 2.7 run power shell (should already be installed on windows) run python IN POWERSHELL (if it doesn't recognize then go to step 4) Only if powershell doesn't recognize python 2.7 type in the following: "[ENVIRONMENT]::SETENVIRONMENTVARIABLE("PATH", "$ENV:PATH;C:\PYTHON27", "USER")" (no outside quotes) Now type python and you should see it say python 2.7 blah blah blah NOW for python 3.x Simple, python 3.x download comes with python for windows app. SO simply pin the Python for Windows app to your task bar, or create shortcut to the desktop and you are done! Open Python for Windows for 3.x Open Powershell for python 2.x I hope this helps!
0
1
0
0
2008-12-04T16:18:00.000
20
0
false
341,184
1
0
0
5
I'm running Windows and the shell/OS automatically runs Python based on the registry settings when you run a program on the command line. Will this break if I install a 2.x and 3.x version of Python on the same machine? I want to play with Python 3 while still being able to run 2.x scripts on the same machine.
Where do I go from here -- regarding programming?
347,065
7
3
775
0
php,asp.net,python,linux
You will only have a first language for a little while. Pick any direction that interests you, and follow it. There is no way around the introduction "Drink from the Firehose" experience. Keep early project simple, and tangible. Build useful things and the motivation will be there. Web / desktop / mobile / etc, its all good. Find the one that gets you thinking about code when your not coding, and you'll know your going in the right direction.
0
1
0
0
2008-12-07T00:49:00.000
9
1.2
true
347,054
0
0
0
7
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
347,353
0
3
775
0
php,asp.net,python,linux
I had the same issue for a little while myself. I was getting bored of just being in PHP and wanted to be able to do more. I ended up settling on C# since it not only fulfilled the 'necessary evil' argument, but allows me to do anything I want in the MS realm, and is the closest syntax wise to another language (Java). Thinking about all the different types of projects this opened me up to made me choose this direction. Both languages can be used for web development, mobile devices, and desktop applications.
0
1
0
0
2008-12-07T00:49:00.000
9
0
false
347,054
0
0
0
7
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
347,348
0
3
775
0
php,asp.net,python,linux
Really all you need to do is make sure you take baby steps and are doing something you are enjoying. I started off programming in visual basic on a little game. Not the best language, but it was a good starting point for me at the time. My point is, you don't need to pick the best language/operating system/anything from the start, just iterate. It is the programming way. By the way, just because you use windows as your OS doesn't mean you have to do everything .NET I use windows and then have a server for all my web hosting that I SSH into.
0
1
0
0
2008-12-07T00:49:00.000
9
0
false
347,054
0
0
0
7
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
347,120
0
3
775
0
php,asp.net,python,linux
I find some of my junior colleagues (atleast the ones that are very passionate about CS) asking similar questions (sometimes I find myself asking this too, even though I am now 12+ yrs into the industry). One advice I give them (and to myself too), which helped me, is - Focus on the job that is already assigned to you. As part of that task, make sure you dont just "get the job done", but also make sure that you understand the fundamentals behind the same. If you want to be a good programmer, you need to understand the underlying principles of "how things work". Using an API to do matrix multiplication is easy, but if you dont really know what is matrix multiplication and how to do it by hand, you are actually losing out. So in your chosen web programming domain, make sure you go beyond the surface. Understand what is really happening behind your back, when you click that button. As part of "doing the job" you typically can figure out what is your interest area. If you are more passionate about how things are implemented, and keep figuring it out, then you are, IMO, a systems guy. If you are more passionate about finding out all the new tools and the newer features and seem to be keen in putting things together to create newer and cooler outputs, then you are an application programmer. Both are interesting areas in their own ways and as people adviced above, realize what you like and see if you can stick with it. And I like one of the advices above. If you are still confused, try doing this "rotation" thingie. There are lots of scope in just about every domain/field and so keep rotating (but give each rotation due time), until you find what you like. All the best. :-)
0
1
0
0
2008-12-07T00:49:00.000
9
0
false
347,054
0
0
0
7
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
347,066
2
3
775
0
php,asp.net,python,linux
The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. This is exactly the course to follow. I think most of us get into programming the same way. Find a problem and work out its solution in whatever technology is appropriate. Keep looking for problems that are interesting to you, and you'll find your own answer (which is probably different than my own answer) to this question.
0
1
0
0
2008-12-07T00:49:00.000
9
0.044415
false
347,054
0
0
0
7
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
347,121
0
3
775
0
php,asp.net,python,linux
Thanks for the thoughtful responses That seemed to be another distraction from learning programming for me anyway. I spent more time chasing apparent fixes for upgraded packages and such. Mostly things that were already working and it just seemed to not make much sense to spend time recreating the wheel so to speak. Believe me the jury is still out for ma as to whether it makes good sense to chase the dream of Linux as a real alternative to a usable desktop. Now remember ex-Windows users will always have to compare their experience with Linux to how they were previously able to work before trying Windows. Just my two cents
0
1
0
0
2008-12-07T00:49:00.000
9
0
false
347,054
0
0
0
7
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Where do I go from here -- regarding programming?
347,076
0
3
775
0
php,asp.net,python,linux
Don't worry so much about the direction you're going, just make sure that: a) You are enjoying it, and are understanding what you are doing. You don't have to initially understand concepts like polymorphism for example, but you should be understanding the basics of what you are doing. Just can't wrap your mind around Tuples and Dictionaries in Python after awhile? Then it's probably not for you. Of course, that's a very low level example as if you don't get Dictionaries, then there's a problem in general :-) b) You are working on things that you want to solve, not just because you think you NEED to learn this. You used the phrase "Windows is a necessary evil" No, it isn't. Many companies (big and small) do not use the .NET platform for development. Your approach to Linux was interesting as you could not achieve something you wanted on it and your result was "it's clunky" which seems kind of awkward. Either way, this isn't about Linux vs. Windows, but I hope that helps. Just go with the flow, and don't worry about what way you're going as long as you're enjoying and learning! :)
0
1
0
0
2008-12-07T00:49:00.000
9
0
false
347,054
0
0
0
7
I seem to be in a never ending tail spin of Linux, or not, Windows or not. Web programming or system programming. Python or PHP. I'am self teaching myself programming. But it seems I keep being torn about which way to go. Unfortunately it is always seemingly good reasons to get side tracked. You know the whole open source or proprietary thing. Lately I have decided after a year that Linux just doesn't cut it for me and it mostly stems from me wanting to watch videos on Channel 9 etc, and the clunkiness that is Linux. So that lead me to, "Should I learn ASP.NET, since I am more so deciding Windows IS a "necessary" evil. I hope this made sense. The reason I settled in on Web Development as my course to learning programming is because I actually have a task to implement rather then aimlessly reading reference books etc. Does anyone have any advice at what they may have done to stay focused and not get lead down every tangent or idea.
Execute Commands Sequentially in Python?
359,737
30
25
51,127
0
python,windows,subprocess
To do that, you would have to: supply the shell=True argument in the subprocess.Popen call, and separate the commands with: ; if running under a *nix shell (bash, ash, sh, ksh, csh, tcsh, zsh etc) & if running under the cmd.exe of Windows
0
1
0
0
2008-12-11T13:30:00.000
5
1
false
359,347
0
0
0
1
I would like to execute multiple commands in a row: i.e. (just to illustrate my need): cmd (the shell) then cd dir and ls and read the result of the ls. Any idea with subprocess module? Update: cd dir and ls are just an example. I need to run complex commands (following a particular order, without any pipelining). In fact, I would like one subprocess shell and the ability to launch many commands on it.
Access CVS through Apache service using SSPI
361,235
0
0
820
0
python,apache,cvs,sspi
Usage of SSPI make me think you are using CVSNT, thus a Windows system; what is the user you are running Apache into? Default user for services is SYSTEM, which does not share the same registry as your current user.
0
1
0
0
2008-12-11T21:05:00.000
1
1.2
true
360,911
0
0
1
1
I'm running an Apache server (v2.2.10) with mod_python, Python 2.5 and Django. I have a small web app that will show the current projects we have in CVS and allow users to make a build of the different projects (the build checks out the project, and copies certain files over with the source stripped out). On the Django dev server, everything works fine. I can see the list of projects in cvs, check out, etc. On the production server (the Apache one) I get the following error: [8009030d] The credentials supplied to the package were not recognized I'm trying to log in to the CVS server using SSPI. Entering the same command into a shell will execute properly. This is the code I'm using: def __execute(self, command = ''): command = 'cvs.exe -d :sspi:user:[email protected]:/Projects ls' p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr = subprocess.STDOUT, shell=True) return p.communicate() I've tried a number of different variations of things, and I can't seem to get it to work. Right now I believe that Apache is the culprit. Any help would be appreciated
Is there anyone who has managed to compile mod_wsgi for apache on Mac OS X Leopard?
392,945
2
4
953
0
python,django,apache
This doesn't directly answer your question, but have you thought about using something like MacPorts for this sort of thing? If you're compiling a lot of software like this, MacPorts can really make your life easier, since building software and dependencies is practically automatic.
0
1
0
0
2008-12-15T18:39:00.000
1
0.379949
false
369,305
0
0
1
1
I'm working on a Django project that requires debugging on a multithreaded server. I've found mod_wsgi 2.0+ to be the easiest to work with, because of easy workarounds for python module reloading. Problem is can't get it to compile on Leopard. Is there anyone who has managed to do it so far, either for the builtin Apache or MAMP. I'd be grateful if someone posts a link to a precompiled binary (for intel, python 2.5, apache 2.2 or 2.0). After 3 hours of trial and error I've managed to compile mod_wsgi 2.3 for the Apache that comes with Leopard. Here are the instructions in case anyone else needs this. ./configure Change 2 lines in the Makefile CFLAGS = -Wc,'-arch i386' LDFLAGS = -arch i386 -Wl,-F/Library/Frameworks -framework Python -u _PyMac_Error make && sudo make install Make a thin binary of the original httpd cd /usr/sbin sudo mv ./httpd ./httpd.fat sudo lipo ./httpd.fat -thin i386 -output ./httpd.i386 sudo ln -s ./httpd.i386 ./httpd This should work on intel macbook, macbook pro, imac and mac mini. As I understood the problem is modwsgi won't compile against MacPython 2.5.2 because of some weird architecture missmatch problem. But, if you compile it as a thin binary it won't play with the Apache fat binary. So this hack solves the problem. The rest is pretty standard configuration, like on any other platform.
Prevent ftplib from Downloading a File in Progress?
375,650
0
4
1,585
0
python,ftp,ftplib
You can't know when the OS copy is done. It could slow down or wait. For absolute certainty, you really need two files. The massive file. And a tiny trigger file. They can mess with the massive file all they want. But when they touch the trigger file, you're downloading both. If you can't get a trigger, you have to balance the time required to poll vs. the time required to download. Do this. Get a listing. Check timestamps. Check sizes vs. previous size of file. If size isn't even close, it's being copied right now. Wait; loop on this step until size is close to previous size. While you're not done: a. Get the file. b. Get a listing AGAIN. Check the size of the new listing, previous listing and your file. If they agree: you're done. If they don't agree: file changed while you were downloading; you're not done.
0
1
0
1
2008-12-17T18:54:00.000
4
0
false
375,620
0
0
0
4
We have a ftp system setup to monitor/download from remote ftp servers that are not under our control. The script connects to the remote ftp, and grabs the file names of files on the server, we then check to see if its something that has already been downloaded. If it hasn't been downloaded then we download the file and add it to the list. We recently ran into an issue, where someone on the remote ftp side, will copy in a massive single file(>1GB) then the script will wake up see a new file and begin downloading the file that is being copied in. What is the best way to check this? I was thinking of grabbing the file size waiting a few seconds checking the file size again and see if it has increased, if it hasn't then we download it. But since time is of the concern, we can't wait a few seconds for every single file set and see if it's file size has increased. What would be the best way to go about this, currently everything is done via pythons ftplib, how can we do this aside from using the aforementioned method. Yet again let me reiterate this, we have 0 control over the remote ftp sites. Thanks. UPDATE1: I was thinking what if i tried to rename it... since we have full permissions on the ftp, if the file upload is in progress would the rename command fail? We don't have any real options here... do we? UPDATE2: Well here's something interesting some of the ftps we tested on appear to automatically allocate the space once the transfer starts. E.g. If i transfer a 200mb file to the ftp server. While the transfer is active if i connect to the ftp server and do a size while the upload is happening. It shows 200mb for the size. Even though the file is only like 10% complete. Permissions also seem to be randomly set the FTP Server that comes with IIS sets the permissions AFTER the file is finished copying. While some of the other older ftp servers set it as soon as you send the file. :'(
Prevent ftplib from Downloading a File in Progress?
375,800
5
4
1,585
0
python,ftp,ftplib
“Damn the torpedoes! Full speed ahead!” Just download the file. If it is a large file then after the download completes wait as long as is reasonable for your scenario and continue the download from the point it stopped. Repeat until there is no more stuff to download.
0
1
0
1
2008-12-17T18:54:00.000
4
1.2
true
375,620
0
0
0
4
We have a ftp system setup to monitor/download from remote ftp servers that are not under our control. The script connects to the remote ftp, and grabs the file names of files on the server, we then check to see if its something that has already been downloaded. If it hasn't been downloaded then we download the file and add it to the list. We recently ran into an issue, where someone on the remote ftp side, will copy in a massive single file(>1GB) then the script will wake up see a new file and begin downloading the file that is being copied in. What is the best way to check this? I was thinking of grabbing the file size waiting a few seconds checking the file size again and see if it has increased, if it hasn't then we download it. But since time is of the concern, we can't wait a few seconds for every single file set and see if it's file size has increased. What would be the best way to go about this, currently everything is done via pythons ftplib, how can we do this aside from using the aforementioned method. Yet again let me reiterate this, we have 0 control over the remote ftp sites. Thanks. UPDATE1: I was thinking what if i tried to rename it... since we have full permissions on the ftp, if the file upload is in progress would the rename command fail? We don't have any real options here... do we? UPDATE2: Well here's something interesting some of the ftps we tested on appear to automatically allocate the space once the transfer starts. E.g. If i transfer a 200mb file to the ftp server. While the transfer is active if i connect to the ftp server and do a size while the upload is happening. It shows 200mb for the size. Even though the file is only like 10% complete. Permissions also seem to be randomly set the FTP Server that comes with IIS sets the permissions AFTER the file is finished copying. While some of the other older ftp servers set it as soon as you send the file. :'(