Detect script start up from command prompt or "double click" on Windows
Is is possible to detect if a Python script was started from the command prompt or by a user "double clicking" a .py file in the file explorer on Windows? ...
Is is possible to detect if a Python script was started from the command prompt or by a user "double clicking" a .py file in the file explorer on Windows? ...
So far, I've had great success using PyAMF to communicate between my Flex front-end and my Django back-end. However, I believe I've encountered a bug. The following example (emphasis on the word "example") demonstrates the (potential) bug: My Flex app contains the following VO: package myproject.model.vo { [Bindable] [RemoteC...
I am debugging a problem in Django with Pydev. I can set breakpoint in my django project code with out a problem. However I can't set breakpoints in the Django library source code (in site-packages). The PyDev debugger user interface in this case simply does nothing when I click to set the breakpoint and does not break at that locatio...
I get a File via a HTTP-Upload and need to be sure its a pdf-file. Programing Language is Python, but this should not matter. I thought of the following solutions: Check if the first bytes of the string are "%PDF". This is not a good check but prevents the use from uploading other files accidentally. Try the libmagic (the "file" comma...
I've got geodjango running using openlayers and OpenStreetMaps with the admin app. Now I want to write some views to display the data. Basically, I just want to add a list of points (seen in the admin) to the map. Geodjango appears to use a special openlayers.js file to do it's magic in the admin. Is there a good way to interface with...
I have a large number of email addresses to validate. Initially I parse them with a regexp to throw out the completely crazy ones. I'm left with the ones that look sensible but still might contain errors. I want to find which addresses have valid domains, so given [email protected] I want to know if it's even possible to send emails to abc...
I have a python script which needs to execute several command line utilities. The stdout output is sometimes used for further processing. In all cases, I want to log the results and raise an exception if an error is detected. I use the following function to achieve this: def execute(cmd, logsink): logsink.log("executing: %s\n" % cmd...
I'm trying to get a list of currently-open sessions in Python via WMI. What I'm after is the exact information displayed in the Computer Management thingy, when you go to System Tools -> Shared Folders -> Sessions (ie username, computer name, connected time, that sort of thing). I know (or at least believe) it has something to do with ...
Alright, I have a Django view, like this: @render_to('home/main.html') def login(request): # also tried Client.objects.select_related().all() clients = Client.objects.all() return {'clients':clients} And I have a template, main.html, like this: <ul> {% for client in clients %} <li>{{ client.full_name }}</li> <ul> ...
How to do conditional compilation in Python ? Is it using DEF ? ...
I need to sort two arrays simultaneously, or rather I need to sort one of the arrays and bring the corresponding element of its associated array with it as I sort. That is if the array is [(5, 33), (4, 44), (3, 55)] and I sort by the first axis (labeled below dtype='alpha') then I want: [(3.0, 55.0) (4.0, 44.0) (5.0, 33.0)]. These are ...
This is the HTML I have: p_tags = '''<p class="foo-body"> <font class="test-proof">Full name</font> Foobar<br /> <font class="test-proof">Born</font> July 7, 1923, foo, bar<br /> <font class="test-proof">Current age</font> 27 years 226 days<br /> <font class="test-proof">Major teams</font> <span style="white-space: nowrap">Japan...
Does anyone know of any GUI designer for python like Glade but for windows? ...
I'm making a game and I am using Python for the server side. It would be fairly trivial to implement chat myself using Python - that's not my question. I was just wondering if there were any premade chat servers or some kind of service that I would be able to implement inside of my game instead of rolling my own? Maybe like a different p...
I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the cleanest way to con...
I am a C# .NET programmer and am learning Python. I have downloaded IronPython, and know that it can call into .NET libraries. I'm wondering whether there is a way to do the reverse, that is to call into some existing "classic" Python libraries in my C# code, maybe using .NET Interop. I'd like to be able to access functions in libra...
I am confused how directory name, file name and class name all work together. This is what I have at the moment app.py database/ client.py staff.py order.py inside client.py I have a single class called client. This class acts as the database model (MVC), the same with my other files (staff.py has a class called st...
My program appears to be leaking file handles, how can I find out where? - My program uses file handles in a few different places - output from child processes, call ctypes api (imagemagick) opens files, and they are copied. It crashes in shutil.copyfile, but I'm pretty sure this is not the place it is leaking Traceback (most recent c...
Hello StackOverflow! I'm creating a small wxPython utility for the first time, and I'm stuck on a problem. I would like to add components to an already created frame. To do this, I am destroying the frame's old panel, and creating a new panel with all new components. 1: Is there a better way of dynamically adding content to a panel?...
hi, I'm running python 2.4 from cgi and I'm trying to upload to a cloud service using a python api. In php, the $_FILE array contains a "tmp" element which is where the file lives until you place it where you want it. What's the equivalent in python? if I do this fileitem = form['file'] fileitem.filename is the name of the file ...