python

python script problem once build and package it

hi expert, I've written python script to scan wifi and send data to the server, I set interval value, so it keep on scanning and send the data, it read from config.txt file where i set the interval value to scan, I also add yes/no in my config file, so is 'no' it will scan only once and if 'yes' it will scan according to the interval lev...

os.stat().st_uid always returns a value of 0 to wsadmin (jython 2.1)

Hi guys, I come a across a tricky issue developing wsadmin code for websphere. No matter what file I choose, os.stat() seems always to give me back a uid = 0. See the following files: -rw-r--r-- 1 tn58660 other 1625 Apr 26 15:03 search.py -rw-r--r-- 1 wasapps wasapp 109 Mar 22 17:27 test.py bash-3.00# /export/opt/W...

How to use nose coverage with --timid flag

I'd like to run "nosetests --with-coverage" using Ned Batchelder's coverage module, but passing the coverage module the --timid flag. Is there a way (e.g. setting an environment variable) to make coverage run with --timid? ...

Convert Google results object (pure js) to Python object

So I'm trying to use Google Map suggest API to request place name suggestions. Unfortunately I can't find the docs for this bit. Here is an example URI: http://maps.google.com/maps/suggest?q=lon&cp=3&ll=55.0,-3.5&spn=11.9,1.2&hl=en&gl=uk&v=2 which returns: {suggestion:[{query:"London",... I want to use this ...

how to render custom columns with a GenericTreeModel

I have to display some data in a treeview. The "real" data model is huge and I cannot copy all the stuff in a TreeStore, so I guess I should use a GenericTreeModel to act like a virtual treeview. Btw the first column is the classic icon+text style and I think I should declare a column with a CellRendererPixbuf (faq sample), but I'm not s...

Is there anyway to get pdb and Mac Terminal to play nicely?

When debugging my django apps I use pdb for interactive debugging with pdb.set_trace(). However, when I amend a file the local django webserver restarts and then I cant see what I type in the terminal, until I type reset. Is there anyway for this to happen automatically? It can be real annoying, having to cancel the runserver and reset...

How to get debugging of an App Engine application working?

I've got 10+ years in C/C++, and it appears Visual Studio has spoilt me during that time. In Visual Studio, debbuging issimple: I just add a breakpoint to a line of code, and as soon as that code is executed, my breakpoint triggers, at which point I can view a callstack, local/member variables, etc. I'm trying to achieve this functiona...

How do I list all classes of a given type in a python file?

I use django, and have a lengthy models.py file. class Foo(models.Model): name = models.CharField() class Bar(models.Model): name = models.CharField() class Fab(models.Model): name = models.CharField() Is there a way to make a list of all the classes in the file which are an instance of (models.Model)? ...

Python, add trailing slash to directory string, os independently

How can I add a trailing slash (/ for *nix, \ for win32) to a directory string, if the tailing slash is not already there? Thanks! ...

Abstract attributes in Python

What is the shortest / most elegant way to implement the following Scala code with an abstract attribute in Python? abstract class Controller { val path: String } A subclass of Controller is enforced to define "path" by the Scala compiler. A subclass would look like this: class MyController extends Controller { override va...

python eval weirdness

Hi Folks I have the following code in one of my classes along with checks when the code does not eval: filterParam="self.recipientMSISDN==tmpBPSS.split('_')[3].split('#')[0] and self.recipientIMSI==tmpBPSS.split('_')[3].split('#')[1]" if eval(filterParam): print "Evalled" else: print "Not Evalled\nfilterParam\n'%s'\ntmpBPSS\n'%...

To stop returning through SSH using Pexpect

Hello, I am trying to use pexpect to ssh into a computer but I do not want to return back to the original computer. The code I have is: #!/usr/bin/python2.6 import pexpect, os def ssh(): # Logs into computer through SSH ssh_newkey = 'Are you sure you want to continue connecting' # my ssh command line p=pexpect.spawn(...

Creating a list in Python- something sneaky going on?

Apologies if this doesn't make any sense, I'm very new to Python! From testing in an interpreter, I can see that list() and [] both produce an empty list: >>> list() [] >>> [] [] From what I've learned so far, the only way to create an object is to call its constructor (__init__), but I don't see this happening when I just type []. S...

how to generate py files without default windows crlf ?

how can I write a .py file from python such that its type should not be like 'ASCII file with Windows CRLF' because when i run file.write(data) inside windows it write the file but when I try to eval(open(file.py).read()) it fails and gives syntax error because of windows CRLF on each line...... see the error log - traceback ERROR:we...

Declaring models elsewhere than in "models.py" AND dynamically

Hi ! I have an application that splits models into different files. Actually the folder looks like : >myapp __init__.py models.py >hooks ... ... myapp don't care about what's in the hooks, folder, except that there are models, and that they have to be imported somehow, and installed by syncdb. So, I put this i...

Does Django cache url regex patterns somehow?

I'm a Django newbie who needs help: Even though I change some urls in my urls.py I keep on getting the same error message from Django. Here is the relevant line from my settings.py: ROOT_URLCONF = 'mydjango.urls' Here is my urls.py: from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: from dja...

Is my approach correct to replicate this form with Reportlab?

I need to generate the form seen here using Python/reportlab. http://www.flickr.com/photos/49740282@N06/4563137758/sizes/o/ I am attempting to do this by creating a custom flowable for the header at the top (with the boxes drawn) and then having a table flowable for the jewelry table below. What shows as the JEWELRY table for this exa...

numpy arange with multiple intervals

Hi, i have an numpy array which represents multiple x-intervals of a function: In [137]: x_foo Out[137]: array([211, 212, 213, 214, 215, 216, 217, 218, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950]) as you can see, in x_foo are two intervals: one from 211 to 218, and one from 940 to 950. these are intervals, which i w...

Python 3 online interpreter / shell

Does anyone know about an online interpreter like http://codepad.org/ or http://try-python.mired.org/ with Python 3? ...

Python line file iteration and strange characters

I have a huge gzipped text file which I need to read, line by line. I go with the following: for i, line in enumerate(codecs.getreader('utf-8')(gzip.open('file.gz'))): print i, line At some point late in the file, the python output diverges from the file. This is because lines are getting broken due to weird special characters tha...