python

reading .bash_history file through python script

I want to write a python script which reads the '.bash_history' file and prints the statistics. Also, I would like to print the command which was used the most. I was able to read the bash history through the terminal but I'm not able to do it through python programming. Can someone please help me with how to start with it? ...

Python-based Torrent Server

Are there any implementations of something like torrage.com torrent-hosting created in Python? ...

Python: Reading Excel 2007 files under Linux environment

Greetings, I want to read excel 2007 files via python on my Ubuntu server. I have already checked http://www.python-excel.org/ xlwt and xlrd but it seems like none of them can read excel 2007 files. What would be your recommendation? Regards ...

Django / Python, Make database save function re-usable (so that it takes modelname and appname from strings), using contenttypes or some other method?

I want to make some functions that are re-usable by any model so that I can specify the appname and model in string format and then use this to import that model and make calls to it such as creating database fields, updating, deleting, etc... I had thought I could do this using contenttypes in Django but am trying this, as below and am...

python print not functioning correctly after using curses

I have created a simple gui with curses. However, when the curses menu is finished the print function does not print anything to screen until the main program exits. In the example below, when calc.py is run, the text "Directory list ok" is printed to the screen after the foo(calcDirs) is run. If I comment out the line folderSelection....

python - edit a text file

hi, I am using python and i want to delete some characters from the end of a text file. The file is big a and i dont want to read all of it and duplicate the interesting part. My best guess is that i need to change the file size.... can anyone help me please thanks ...

How to create a simple mesh in Blender 2.50 via the Python API

I would like to create a simple mesh in Blender (2.50) via the Python API but the examples from the API documentation don't work yet. I tried the following but it's from API 2.49 from Blender import * import bpy editmode = Window.EditMode() # are we in edit mode? If so ... if editmode: Window.EditMode(0) # leave edit ...

How to reset global variable in python?

SOME_VARIABLE = [] def some_fun: append in SOME_VARIABLE s = [] s = SOME_VARIABLE SOME_VARIABLE = [] // Not setting to empty list. return s How to reset SOME_VARIABLE to empty. ...

Best way to know that my Python Code base is using PyXML or not ?

I have a python code base and want to know whether pyxml is really used in the code any where. The python version i have is 2.6. pyxml's last binary distribution ended with 2.4 python version. Any clues or ideas to judge the code whether it is free of pyxml 0.8.4 on python 2.6 ? Thanks in Advance. ...

Python: Installing man pages in distutils based project

Hello, I have a Python project which is basically a set of command line scripts and a helper package. As these scripts have a number of command line options I decided to create a manual page for each script and used ronn (http://rtomayko.github.com/ronn/) to write manuals in Markdown and generate mdoc from it. The question is: how to g...

Twisted and connection to MSSQL-Server

I have a Twisted application that runs in an x86 64bit machine with Win 2008 server. It needs to be connected to an MSSQL-Server database that runs in another machine (in a cloud actually but I have IP, port, db name, credentials). Do I need to install anything more that Twisted to my machine? And which API should be used? ...

How Do You Predict A Non-Linear Script's Run Time?

I wrote this simple code in python to calculate a given number of primes. The question I want to ask is whether or not it's possible for me to write a script that calculates how long it will take, in terms of processor cycles, to execute this? If yes then how? primes = [2] pstep = 3 count = 1 def ifprime (a): """ Checking if the pass...

how to have gantt chart using python or pyqt

hello , im working on a (asset management) system to handle assets , resources and progress of tasks i want to have a gantt chart in my system im using python 2.6 and pyqt . is there any (already made charts python library ) ? that can work well with pyqt. or should i make a custom widgets for this ? please advice. thanks in advance...

How to import the Python async module from a worker thread?

I'm using the GitPython package to access a Git repository from Python. This pulls in the async package. In async/__init__.py, the following happens: def _init_signals(): """Assure we shutdown our threads correctly when being interrupted""" import signal # ... signal.signal(signal.SIGINT, thread_interrupt_handler) _init...

inverted comma and string in python..

I'm kinda' new to python, but I have already written many programs including some like download-managers, games and text-editors which require a lot of string manipulation. For representing a string literal I use either single or double inverted commas.. whichever comes to my mind first at that time. Although I haven't yet faced any tro...

Numpy matrix operations

I want to compute the following values for all i and j: M_ki = Sum[A_ij - A_ik - A_kj + A_kk, 1 <= j <= n] How can I do it using Numpy (Python) without an explicit loop? Thanks! ...

How to test a web API throttle limit in Python

I would like to test a web API throttle limit of a given site using Python. This API throttle limit allows X requests MAX over Y seconds per IP. I would like to be able to test the reliability of this throttle limit, in particular on border cases (X-1 requests, X+1 requests) Could you suggest a good way to do it? ...

Testing workflows in Django

Hi folks, I really love testing and building unit tests, but I find it quite annoying having to build tests for a website's workflow. e.g. Register -> Check email -> Activate account -> Login or Login -> Edit details -> Submit and view profile manual testing = loads of time + tireing even when using app such as Selenium, going t...

How to execute another python script from your script and be able to debug?

You have wrapper python script that is calling another python script, currently using os.system('python another.py some-params'). You want to be able to debug both scripts and if you use os.system() you'll loose the debugger, so it does make sense to load the second script using the same interpretor instead of starting another one. imp...

Automation of Open Zoom

How would I automate the process of deploying a gigantic jpeg on a web server and then generate the necessary files to load the image up on the frontend site in OpenZoom? I'm working in php but any shell/bash/python scripts are welcome ...