I am writing a small app that has to perform some 'sanity checks' before entering execution. (eg. of a sanity check: test if a certain path is readable / writable / exists)
The code:
import logging
import os
import shutil
import sys
from paths import PATH
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('sf.core.sanity...
I am running a Python program on a Windows XP machine. When I run the program, I get the following error:
File "C:\Python27\lib\pysnmp\smi\builder.pyt, line 230, in loadModules...
pysnmp.smi.error.SmiError: MIB file "SNMPv2-MIB.py[co]" not found in search path
Does anyone know how I can solve this? The file SNMPv2-MIB.py is currently l...
I want to use Twisted to rebuild the communication part of an existing application. This application does send data from the client to the server, only this way round, the server does not send anything.
How do I accomplish this with the event-driven concept of Twisted? I currently use the connectionMade method of Protocol, but I don't t...
Hello,
I read this somewhere a while ago but cant seem to find it. I am trying to find a command that will execute commands in the terminal and then output the result.
For example: the script will be:
command 'ls -l'
It will out the result of running that command in the terminal
...
Does Python or any of its modules have an equivalent of MATLAB's conv2 function? More specifically, I'm interested in something that does the same computation as conv2(A, B, 'same') in MATLAB.
...
I'm trying to create a url pattern that will behave like controller/action/id route in rails. So far here is what I have :
from django.conf.urls.defaults import *
import views
urlpatterns = ('',
(r'^(?P<app>\w+)/(?P<view>\w+)/$', views.select_view),
)
Here is my 'views.py':
def select_view(request, app, v...
I have this code:
def random_answerlist(self):
self.li = []
self.winning_button = random.randint(0, 3)
i = 0
while i < 20 and len(self.li) is not 4:
if i == self.winning_button:
self.li.append(self.flags[self.current_flag][0])
else:
new_value = self.random_value()
if se...
I have a hex value that I'm grabbing from a text file, then I'm passing it to a2b_hex to convert it to the proper binary representation. Here is what I have:
k = open('./' + basefile + '.key', 'r')
k1 = k.read()
k.close()
my_key = binascii.a2b_hex(k1)
When I print k1, it is as expected: 81e3d6df
Here is the error message:
Traceback...
I have built a couple of test cases as stand alone python classes using Selenium. I can run each of them using Selenium RC. Ultimately I want to use Selenium Grid to run all of the test cases.
How would I do this?
Do I need some kind of wrapper to hold of of the python test cases together? How do I get Selenium Grid to run a collectio...
How can I replace the contents of strings with #'s in Python? Assume no comments, no multiple lines for one string. Like if there is a line in a python file:
print 'Hello' + "her mom's shirt".
This will be translated into:
print '#####' + "###############".
It's like a filter to deal with every line in a python file.
...
Hi Everyone,
I am trying to use urllib3 in simple thread to fetch several wiki pages.
The script will
Create 1 connection for every thread (I don't understand why) and Hang forever.
Any tip, advice or simple example of urllib3 and threading
import threadpool
from urllib3 import connection_from_url
HTTP_POOL = connection_from_url(url...
Let's say I have two data sets. I have a week-by-week tally of users who tried my service.
trials = [2,2,2,8,8,4]
And I have a week by week tally of trial users who signed up.
conversions = [1,0,2,4,8,3]
I can do it pretty quickly this way:
conversion_rate = []
for n in range(len(trials)):
conversion_rate.append(conversions[n]/...
Initially i thought to do something like:
#EXIT CODES
class ExitCode(object):
(USERHOME_INVALID, \
USERHOME_CANNOT_WRITE, \
USERHOME_CANNOT_READ, \
BASHRC_INVALID) = range(-1, -5, -1)
But than I've realized that I'll have to know exactly the total number of EXIT_CODES, so that I can pass it to the range() function. Let...
I want to detect whenever the selection of my gtk.TreeView changes and, when it does, to call a function w/ this information. The only way I've found to do it so far is to attach to all these signals:
...
self.sitterView.connect("cursor-changed", self.selectionChanged)
self.sitterView.connect("unselect-all", self.selectionChange...
I'm testing out some of the examples in Rapid GUI Programming with Python and Qt, but running into a stumbling block here or where. When I copied to following exercise (verbatim, from the book):
import sys
import time
from PyQt4.QtCore import *
from PyQt4.QtGui import *
app = QApplication(sys.argv)
try:
due = QTime.currentTime()
...
Hi all !
I am currently implementing a django app, for this I try to use a syntax that is consistent with Django's...
So here is what I am trying :
class Blablabla(Model):
#this contains Blablabla's options
class Meta:
sort_key = lambda e: e
sort_key is a key function (for sorting purposes), but of course, it is und...
Is there a way to send an interrupt to a python module when the user inputs something in the console? For example, if I'm running an infinite while loop, i can surround it with a try/except for KeyboardInterrupt and then do what I need to do in the except block.
Is there a way to duplicate this functionality with any arbitrary input? Ei...
Not sure if this has a straightforward solution, but I want to write a function that shows a dialog (defined elsewhere in a class that inherits QDialog) and returns the user input when the user has finished interacting with the dialog. In other words, something similar to the QFileDialog::getOpenFileName static method, where a single lin...
I really like py.test, but I am having lots of difficulty understanding how funcargs work.
Is it possible to use a command line argument or an extension to enable the use of something that performs a similar role to unittest.TestCase.setUp and unittest.TestCase.tearDown?
...
Is there a form(or any other solution) that allows me to quickly build forms that display lists of models(with filtering, ordering etc) like the django admin site does?
...