Available Count
int64
1
31
AnswerCount
int64
1
35
GUI and Desktop Applications
int64
0
1
Users Score
int64
-17
588
Q_Score
int64
0
6.79k
Python Basics and Environment
int64
0
1
Score
float64
-1
1.2
Networking and APIs
int64
0
1
Question
stringlengths
15
7.24k
Database and SQL
int64
0
1
Tags
stringlengths
6
76
CreationDate
stringlengths
23
23
System Administration and DevOps
int64
0
1
Q_Id
int64
469
38.2M
Answer
stringlengths
15
7k
Data Science and Machine Learning
int64
0
1
ViewCount
int64
13
1.88M
is_accepted
bool
2 classes
Web Development
int64
0
1
Other
int64
1
1
Title
stringlengths
15
142
A_Id
int64
518
72.2M
1
2
0
2
2
0
0.197375
0
I use the remote API for some utility tasks, and I've noticed that it is orders of magnitude slower than code running on Appengine. A simple get_by_id(list) took a couple of minutes using the remote API, and a couple of seconds running on Appengine. The logs show that the remote API fetched separately taking a couple of seconds each; whereas on Appengine the whole list of objects is retrieved in about the same time. Is there any way to improve this situation?
0
python,google-app-engine
2012-05-01T04:24:00.000
1
10,393,531
Don't forget that the remoteapi executes your code locally and only calls appengine servers for datastore/blobstore/etc. operations. So in essence, you're running code that's hitting a database living over the network. It's definitely slower.
0
415
false
1
1
Remote API is extremely slow
10,398,726
1
2
0
0
4
1
0
0
I am trying to execute simple JavaScript code in a pure Python environment (Google AppEngine). I've tried PYJON, but it does not seem mature enough for real use(it does not handle eg forward referenced functions or do-while and it hangs on array usage). One idea would be to use pynarcissus to convert JavaScript into a syntax tree and than convert this tree jnto a Python AST which could be compiled into Python bytecode. Has anybody done this before? Any problems with this idea?
0
javascript,python,google-app-engine
2012-05-01T13:26:00.000
0
10,398,315
To my knowledge, there are no complete and robust implementations of Javascript interpreters on Python. Your best option is probably to deploy an alternate version of your app with the Rhino interpreter in Java, and call this as a web service with the main version of your app.
0
846
false
1
1
Converting JavaScript into Python bytecode
10,406,398
1
1
0
2
2
0
0.379949
0
I've been trying to build boost python for about two days now and am incredibly frustrated. When I build the library, it tells me that it was built successfully. When I try to run anything using the library i get errors such as; undefined reference to imp__ZN5boost6python6detail11init_moduleEPKcPFvvE In function ZNK5boost6python9type_info4nameEv: undefined reference to imp__ZN5boost6python6detail12gcc_demangleEPKc I have absolutely no idea why this is happening, but I'd appreciate any ideas BTW, I'm using boost1.49.0 with python 3.0 and the other libraries seem to have been built fine. I've already used the serialization library and it works. Let me know if you need any more info. Thanks.
0
c++,python,boost,windows-7,boost-python
2012-05-01T20:14:00.000
0
10,403,720
Ah, I got it figured out. The problems were python 3 and boost wasn't properly linking the static libraries. I switched to python2.7 and defined BOOST_PYTHON_STATIC_LIB before loading any headers. Everything works fine now. Thanks for the help.
0
362
false
0
1
Building Boost Python with mingw on Windows7 64bit
10,486,821
2
3
0
1
2
0
0.066568
0
I need to convert the GPIB to USB using NI-488.2 from national instrument and I need to create a software complete with GUI using python. The old machine that my company use for measuring is Model 273A potentiostat/galvanostat from Princeton Applied Research. Im using windows 7 and python 2.7 using wxpython. And I need to program using python. I just need to send simple command for example R to run the machine. Connections : from measuring machine via GPIB to NI-488.2(a card to convert GPIB to usb) from NI-488.2 to pc via usb The questions are : How can I send any command to the machine? From what I know, I need to send it to the driver of the NI-488.2. Is it correct? (if correct see ques. 2 if not jump to ques. 3) How can I send from my own code using python to the NI-488.2 driver? How to see the code of any driver? But in my case the driver for NI-488.2. (the driver can be downloaded for free in the national instrument website but registration needed)
0
python,usb,driver,gpib
2012-05-02T10:06:00.000
0
10,411,605
Install the necessary drivers, probably NI 488.2 and NI Visa. Then use pyvisa, a python wrapper around visa, to talk to the device.
0
2,429
false
0
1
converting GPIB to USB using NI-488.2
14,773,570
2
3
0
2
2
0
0.132549
0
I need to convert the GPIB to USB using NI-488.2 from national instrument and I need to create a software complete with GUI using python. The old machine that my company use for measuring is Model 273A potentiostat/galvanostat from Princeton Applied Research. Im using windows 7 and python 2.7 using wxpython. And I need to program using python. I just need to send simple command for example R to run the machine. Connections : from measuring machine via GPIB to NI-488.2(a card to convert GPIB to usb) from NI-488.2 to pc via usb The questions are : How can I send any command to the machine? From what I know, I need to send it to the driver of the NI-488.2. Is it correct? (if correct see ques. 2 if not jump to ques. 3) How can I send from my own code using python to the NI-488.2 driver? How to see the code of any driver? But in my case the driver for NI-488.2. (the driver can be downloaded for free in the national instrument website but registration needed)
0
python,usb,driver,gpib
2012-05-02T10:06:00.000
0
10,411,605
You need to install the driver for the GPIB-USB cable, and registration process is quite simple. For the registration, basically you just need to leave a email address of yours. After you install the driver, you can find many useful information in their "help". Generally you need to read the user manual of your device. The idea is that you should use ctypes to interface with the GPIB-USB's dll in Python.
0
2,429
false
0
1
converting GPIB to USB using NI-488.2
10,613,554
2
4
0
0
7
0
0
0
I want to have simple program in python that can process different requests (POST, GET, MULTIPART-FORMDATA). I don't want to use a complete framework. I basically need to be able to get GET and POST params - probably (but not necessarily) in a way similar to PHP. To get some other SERVER variables like REQUEST_URI, QUERY, etc. I have installed nginx successfully, but I've failed to find a good example on how to do the rest. So a simple tutorial or any directions and ideas on how to setup nginx to run certain python process for certain virtual host would be most welcome!
0
python,nginx,web,fastcgi
2012-05-02T10:39:00.000
0
10,412,063
All the same you must use wsgi server, as nginx does not support fully this protocol.
0
7,440
false
1
1
How to run nginx + python (without django)
10,412,251
2
4
0
4
7
0
1.2
0
I want to have simple program in python that can process different requests (POST, GET, MULTIPART-FORMDATA). I don't want to use a complete framework. I basically need to be able to get GET and POST params - probably (but not necessarily) in a way similar to PHP. To get some other SERVER variables like REQUEST_URI, QUERY, etc. I have installed nginx successfully, but I've failed to find a good example on how to do the rest. So a simple tutorial or any directions and ideas on how to setup nginx to run certain python process for certain virtual host would be most welcome!
0
python,nginx,web,fastcgi
2012-05-02T10:39:00.000
0
10,412,063
You should look into using Flask -- it's an extremely lightweight interface to a WSGI server (werkzeug) which also includes a templating library, should you ever want to use one. But you can totally ignore it if you'd like.
0
7,440
true
1
1
How to run nginx + python (without django)
10,417,619
2
2
0
11
30
0
1
0
I have some management commands that are based on gevent. Since my management command makes thousands to requests, I can turn all socket calls into non-blocking calls using Gevent. This really speeds up my application as I can make requests simultaneously. Currently the bottleneck in my application seems to be Postgres. It seems that this is because the Psycopg library that is used for connecting to Django is written in C and does not support asynchronous connections. I've also read that using pgBouncer can speed up Postgres by 2X. This sounds great but it would be great if someone could explain how pgBouncer works and helps? Thanks
0
python,django,postgresql,connection-pooling,pgbouncer
2012-05-02T18:34:00.000
0
10,419,665
PgBouncer reduces the latency in establishing connections by serving as a proxy which maintains a connection pool. This may help speed up your application if you're opening many short-lived connections to Postgres. If you only have a small number of connections, you won't see much of a win.
0
41,803
false
1
1
How does pgBouncer help to speed up Django
10,419,731
2
2
0
105
30
0
1.2
0
I have some management commands that are based on gevent. Since my management command makes thousands to requests, I can turn all socket calls into non-blocking calls using Gevent. This really speeds up my application as I can make requests simultaneously. Currently the bottleneck in my application seems to be Postgres. It seems that this is because the Psycopg library that is used for connecting to Django is written in C and does not support asynchronous connections. I've also read that using pgBouncer can speed up Postgres by 2X. This sounds great but it would be great if someone could explain how pgBouncer works and helps? Thanks
0
python,django,postgresql,connection-pooling,pgbouncer
2012-05-02T18:34:00.000
0
10,419,665
Besides saving the overhead of connect & disconnect where this is otherwise done on each request, a connection pooler can funnel a large number of client connections down to a small number of actual database connections. In PostgreSQL, the optimal number of active database connections is usually somewhere around ((2 * core_count) + effective_spindle_count). Above this number, both throughput and latency get worse. NOTE: Recent versions have improved concurrency, so in 2022 I would recommend something more like ((4 * core_count) + effective_spindle_count). Sometimes people will say "I want to support 2000 users, with fast response time." It is pretty much guaranteed that if you try to do that with 2000 actual database connections, performance will be horrible. If you have a machine with four quad-core processors and the active data set is fully cached, you will see much better performance for those 2000 users by funneling the requests through about 35 database connections. To understand why that is true, this thought experiment should help. Consider a hypothetical database server machine with only one resource to share -- a single core. This core will time-slice equally among all concurrent requests with no overhead. Let's say 100 requests all come in at the same moment, each of which needs one second of CPU time. The core works on all of them, time-slicing among them until they all finish 100 seconds later. Now consider what happens if you put a connection pool in front which will accept 100 client connections but make only one request at a time to the database server, putting any requests which arrive while the connection is busy into a queue. Now when 100 requests arrive at the same time, one client gets a response in 1 second; another gets a response in 2 seconds, and the last client gets a response in 100 seconds. Nobody had to wait longer to get a response, throughput is the same, but the average latency is 50.5 seconds rather than 100 seconds. A real database server has more resources which can be used in parallel, but the same principle holds, once they are saturated, you only hurt things by adding more concurrent database requests. It is actually worse than the example, because with more tasks you have more task switches, increased contention for locks and cache, L2 and L3 cache line contention, and many other issues which cut into both throughput and latency. On top of that, while a high work_mem setting can help a query in a number of ways, that setting is the limit per plan node for each connection, so with a large number of connections you need to leave this very small to avoid flushing cache or even leading to swapping, which leads to slower plans or such things as hash tables spilling to disk. Some database products effectively build a connection pool into the server, but the PostgreSQL community has taken the position that since the best connection pooling is done closer to the client software, they will leave it to the users to manage this. Most poolers will have some way to limit the database connections to a hard number, while allowing more concurrent client requests than that, queuing them as necessary. This is what you want, and it should be done on a transactional basis, not per statement or connection.
0
41,803
true
1
1
How does pgBouncer help to speed up Django
10,420,469
3
3
0
2
1
1
0.132549
0
I have a problem when I run a script with python. I haven't done any parallelization in python and don't call any mpi for running the script. I just execute "python myscript.py" and it should only use 1 cpu. However, when I look at the results of the command "top", I see that python is using almost 390% of my cpus. I have a quad core, so 8 threads. I don't think that this is helping my script to run faster. So, I would like to understand why python is using more than one cpu, and stop it from doing so. Interesting thing is when I run a second script, that one also takes up 390%. If I run a 3rd script, the cpu usage for each of them drops to 250%. I had a similar problem with matlab a while ago, and the way I solved it was to launch matlab with -singlecompthread, but I don't know what to do with python. If it helps, I'm solving the Poisson equation (which is not parallelized at all) in my script. UPDATE: My friend ran the code on his own computer and it only takes 100% cpu. I don't use any BLAS, MKL or any other thing. I still don't know what the cause for 400% cpu usage is. There's a piece of fortran algorithm from the library SLATEC, which solves the Ax=b system. That part I think is using a lot of cpu.
0
python,multithreading,parallel-processing,cpu-usage
2012-05-03T08:42:00.000
0
10,427,900
Your code might be calling some functions that uses C/C++/etc. underneath. In that case, it is possible for multiple thread usage. Are you calling any libraries that are only python bindings to some more efficiently implemented functions?
1
1,390
false
0
1
Stop Python from using more than one cpu
10,428,163
3
3
0
1
1
1
0.066568
0
I have a problem when I run a script with python. I haven't done any parallelization in python and don't call any mpi for running the script. I just execute "python myscript.py" and it should only use 1 cpu. However, when I look at the results of the command "top", I see that python is using almost 390% of my cpus. I have a quad core, so 8 threads. I don't think that this is helping my script to run faster. So, I would like to understand why python is using more than one cpu, and stop it from doing so. Interesting thing is when I run a second script, that one also takes up 390%. If I run a 3rd script, the cpu usage for each of them drops to 250%. I had a similar problem with matlab a while ago, and the way I solved it was to launch matlab with -singlecompthread, but I don't know what to do with python. If it helps, I'm solving the Poisson equation (which is not parallelized at all) in my script. UPDATE: My friend ran the code on his own computer and it only takes 100% cpu. I don't use any BLAS, MKL or any other thing. I still don't know what the cause for 400% cpu usage is. There's a piece of fortran algorithm from the library SLATEC, which solves the Ax=b system. That part I think is using a lot of cpu.
0
python,multithreading,parallel-processing,cpu-usage
2012-05-03T08:42:00.000
0
10,427,900
You can always set your process affinity so it run on only one cpu. Use "taskset" command on linux, or process explorer on windows. This way, you should be able to know if your script has same performance using one cpu or more.
1
1,390
false
0
1
Stop Python from using more than one cpu
10,429,302
3
3
0
1
1
1
0.066568
0
I have a problem when I run a script with python. I haven't done any parallelization in python and don't call any mpi for running the script. I just execute "python myscript.py" and it should only use 1 cpu. However, when I look at the results of the command "top", I see that python is using almost 390% of my cpus. I have a quad core, so 8 threads. I don't think that this is helping my script to run faster. So, I would like to understand why python is using more than one cpu, and stop it from doing so. Interesting thing is when I run a second script, that one also takes up 390%. If I run a 3rd script, the cpu usage for each of them drops to 250%. I had a similar problem with matlab a while ago, and the way I solved it was to launch matlab with -singlecompthread, but I don't know what to do with python. If it helps, I'm solving the Poisson equation (which is not parallelized at all) in my script. UPDATE: My friend ran the code on his own computer and it only takes 100% cpu. I don't use any BLAS, MKL or any other thing. I still don't know what the cause for 400% cpu usage is. There's a piece of fortran algorithm from the library SLATEC, which solves the Ax=b system. That part I think is using a lot of cpu.
0
python,multithreading,parallel-processing,cpu-usage
2012-05-03T08:42:00.000
0
10,427,900
Could it be that your code uses SciPy or other numeric library for Python that is linked against Intel MKL or another vendor provided library that uses OpenMP? If the underlying C/C++ code is parallelised using OpenMP, you can limit it to a single thread by setting the environment variable OMP_NUM_THREADS to 1: OMP_NUM_THREADS=1 python myscript.py Intel MKL for sure is parallel in many places (LAPACK, BLAS and FFT functions) if linked with the corresponding parallel driver (the default link behaviour) and by default starts as many compute threads as is the number of available CPU cores.
1
1,390
false
0
1
Stop Python from using more than one cpu
10,445,816
1
2
0
12
11
0
1
0
Is there a built in way to save the pylint report to a file? It seems it might be useful to do this in order to log progress on a project and compare elements of reports across multiple files as changes are made.
0
python,pylint
2012-05-03T21:20:00.000
0
10,439,481
You can redirect its output in your shell using > somefile.txt In case it writes to stderr, use 2>&1 > somefile.txt
0
11,281
false
0
1
save pylint message to a file
10,439,541
1
1
0
2
1
1
1.2
0
There are a lot of questions and answers on how to parse/create config files in python and C++ individually. In my case, I have one single config file and need to be processed (read/write) by both python and C++. In python world, ConfigParser is popular; while in C++, libconfig looks nice. But they are using different formats. What I am looking for is a stone being able to kill two birds at the same time. :)
0
c++,python,configuration
2012-05-03T23:53:00.000
0
10,440,924
An obvious solution that comes to mind is to go with something along the lines of YAML or JSON which you should find support for across many languages.
0
404
true
0
1
Config File Process in Python and C++
10,441,128
1
1
0
0
1
0
0
1
I was looking for a Whois Api, but most of them charge heavy price and not reliable enough. We can code in Python or Php. We need to make a Whois lookup service, to integrate with our site. What AWS Resource we need for this? We need at least 5k lookups per day. AWS provides: S3 , elastic, and others. We are confused. As Amazon provides free tire. Does it allow who is lookup? As google app engine never allowed this.
0
php,python,amazon-web-services,whois
2012-05-04T11:30:00.000
0
10,447,970
The Amazon service you want to use is the server service: EC2. You get full access to a server and, of course, you can performs socket connections on port 43 (the one required by the Whois protocol).
0
766
false
0
1
Amazon AWS For Whois?
10,679,625
2
2
1
0
0
1
0
0
I have a problem where it is beneficial for me to be able to mix python code and C++ code, and I think that the task is simple enough that it could be done by simply initializing the C++ program from python, and then having the C++ program "wait" for python to give it some input via std in, and then have python "wait" for the C++ program do its computation and return it via std out etc. I feel like this is either trivial or extremely extremely hard. My main problem is that each time I initialize the C++ code it takes an extremely long time, but that would only need to be done once if I can get this idea implemented. Any thoughts?
0
c++,python,stdout,stdin
2012-05-04T17:58:00.000
0
10,453,841
Sounds like SWIG might be what you're looking for. Use it to generate an extension module for Python, then call your C++ methods from a Python script.
0
314
false
0
1
Mixing python and C++ via std in and std out
10,453,984
2
2
1
0
0
1
1.2
0
I have a problem where it is beneficial for me to be able to mix python code and C++ code, and I think that the task is simple enough that it could be done by simply initializing the C++ program from python, and then having the C++ program "wait" for python to give it some input via std in, and then have python "wait" for the C++ program do its computation and return it via std out etc. I feel like this is either trivial or extremely extremely hard. My main problem is that each time I initialize the C++ code it takes an extremely long time, but that would only need to be done once if I can get this idea implemented. Any thoughts?
0
c++,python,stdout,stdin
2012-05-04T17:58:00.000
0
10,453,841
Look at the the Submodule library. You can use Submodule.popen() to create a process from python, using stdin=PIPE and stdout=PIPE. You can then read from the C++ program's stdout and write to its stdin.
0
314
true
0
1
Mixing python and C++ via std in and std out
10,454,012
1
2
0
1
1
1
0.099668
0
I have some python code which runs every 10 minutes or so. It reads in data, does some processing and produces an output. I'd like to change this so the it runs continuously. Is python well suited for running as a server (asin running continuously) or would I be better off converting my application to use c++? If I leave it in python, are there any modules you would reccomend for achieving this? Thanks
0
c++,python
2012-05-05T09:37:00.000
0
10,460,601
Python can use as a server application. I can remember many web and ftp servers written in python. See in threading library for threads.
0
160
false
0
1
Using python as a server
10,460,624
1
1
0
0
0
0
0
1
Twitter, Facebook and some other websites are blocked in my country. And I want to call the open API to do some hacking. I have searched but it can't solve my problem. Any python libraries can help me sign the OAuth request through proxy and get the access token ? Thanks.
0
python,oauth,proxy
2012-05-07T13:33:00.000
0
10,483,013
I am guessing you will have to set up your own proxy service for this, i.e set up your entire API and OAuth logic on a server outside your own country. If you call this proxy service from within your own country it is probably not apparent that you are actually communicating with Twitter. You will need some sort of cryptographic layer between your client and your proxy/relay service though to make it somewhat secure/obscure. Your own request signing mechanism so to say, and your proxy/relay endpoint should definitely talk (HTTPS/SSL).
0
771
false
0
1
How can I sign OAuth with proxy
10,496,221
1
2
0
0
1
0
0
0
When I import the wx module in a python interpreter it works as expect. However, when I run a script (ie. test.py) with wx in the imports list, I need to write "python test.py" in order to run the script. If I try to execute "test.py" I get an import error saying there is no module named "wx". Why do I need to include the word python in my command? PS the most helpful answer I found was "The Python used for the REPL is not the same as the Python the script is being run in. Print sys.executable to verify." but I don't understand what that means.
0
python,import,module,wxwidgets
2012-05-07T21:05:00.000
0
10,489,126
If you start your script with something like #!/usr/local/bin/python (but using the path to your python interpreter) you can run it without including python in your command, like a bash script.
0
383
false
0
1
importing the wx module in python
10,489,311
1
1
0
0
2
0
0
1
I am having weird behaviors in my Python environment on Mac OS X Lion. Apps like Sublime Text (based on Python) don't work (I initially thought it was an app bug), and now, after I installed hg-git, I get the following error every time I lauch HG in term: *** failed to import extension hggit from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-package/hggit/: [Errno 2] No such file or directory So it probably is a Python environment set up error. Libraries and packages are there in place. Any idea how to fix it? Notes: I installed hg-git following hg-git web site directions. I also added the exact path to the extension in my .hgrc file as: hggit = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-package/hggit/ Python was installed using official package on Python web site. Echoing $PYTHONPATH in term print anything
0
python,mercurial,path,pythonpath
2012-05-09T05:43:00.000
0
10,510,450
"site-package"? Did you mean "site-packages"?
0
2,128
false
0
1
Python: Failed to import extension - Errno 2
10,510,460
1
2
0
4
0
0
0.379949
0
My actual work is to find mood of song i.e. either a sad song or a happy song. I try to find frequencies of mp3 file with fft but it just give the frequencies of small files, like ringtone. Can you guide me which audio feature, such as pitch, timbre, loudness, tempo, could be use to find mood of a songs which are in current playlist? And is it neccessary for this to find frequencies? And I am working in python 2.6 with module tkinter.
0
python,python-2.6
2012-05-09T08:38:00.000
0
10,512,569
Here's one way - find the lyrics on the web and train a classifier to determine if the lyrics are sad or happy. Even if you wont get good enough accuracy this way you could use it as part of the solution in conjunction with the harmony/melody analysis.
0
3,877
false
0
1
How to find mood from song
10,512,800
1
1
0
0
0
1
0
0
I have a function(say method1) imports hashmap in a python file (say file1.py) and it invokes another method (say method2) in another py file (file2.py) not having the import but method2 uses hashmap. When method1 is invoked inside WLST.sh, no problem. But when I invoke it as $MW_HOME/oracle_common/bin/wlst.sh file1.py NameError: HashMap Note: I can't modify file2.py as it already shipped to customer. Thanks, Ashok
0
python,jython,wlst
2012-05-09T09:06:00.000
0
10,512,965
When the name of the variable used to do something like print or use in some other expression without assigning the value for the variable before it was defined then WLST/Python will raises NameError. Check that your HashMap varialbe assigned with value and then sent for other Python script.
0
165
false
0
1
Package importing issue in jython file
11,896,984
1
1
0
0
0
0
0
0
I have a problem when running some python scripts. I get the message 'Ran 0 tests in 0.000s'. This occured out of know where. Soem scripts still do work however. I can't find any difference between the scripts as why some should run and some don't. I've done a bit of research and 'unittest' seems to be a common theme. As far as I know I dind't change my code and I've included import unittest. I don't feel there is a need to post my code as there's no difference (except for the name odf the file) between the scripts that run and the scripts that don't run. Any ideas?
0
python,selenium
2012-05-09T14:00:00.000
0
10,517,696
You are running them as unittests instead of normally. Are you using Eclipse? You're probably pressing the wrong button.
0
196
false
0
1
Python Scripts no longer run
10,517,715
1
1
0
0
3
0
0
0
I have a java application as server (installed on Tomcat/Apache) and another java application as client. The client's task is to get some arguments and pass them to the server and call an adequate method on the server to be execute. I want to have the client in other languages like Perl, Python or TCL. So, I‌ need to know how to establish the communication and what is the communication structure. I'm not seeking for some codes but rather to know more about how to execute some java codes via other languages. I try to google it, but I mostly found the specific question/answer and not a tutorial or something like that. I wonder if I should search for a specific expression ? Do you know any tutorial or site whom explains such structures considering all aspects ? Many thanks Bye.
0
java,python,perl,client
2012-05-09T15:42:00.000
1
10,519,454
What you are talking about is Web Services. A corollary to this is XML and SOAP. In Java, Python, C#, C++... any language, you can create a Web Service that conforms to a standard pattern. Using NetBeans (Oracle's Java IDE) it is easy to create Java web services. Otherwise, use google to search for "web services tutorial [your programming language]
0
114
false
1
1
Execute java methodes via a Python or Perl client
10,519,519
2
2
0
3
2
1
0.291313
0
I'm running Windows 7 64bit as my Host OS and Debian AMD64 as my Guest OS. On my Windows machine a folder called www is mounted on Debian under /home/me/www. I have no problem installing Plone on Debian (the guest OS) with the unified installer. However, when I try to change the default install path from /home/me/Plone to /home/me/www/plone, the installation always fails because Python fails to install. In the install.log it says ln: failed to create hard link 'python' => 'python2.6': Operation not permitted It looks like it might have something to do with access permissions, but I have tried to run the install script either using sudo or as a normal user, none of it helps. The script installs fine elsewhere, just not in the shared folder in Virtualbox. Any suggestions? More Information: I don't have a root account on Debian (testing, System Python version is 2.7) and always use sudo.
0
python,debian,plone,virtualbox,zope
2012-05-09T21:47:00.000
1
10,524,564
I've done some experimenting with VirtualBox recently. It's great, but I'm pretty sure that the shared folders are going to be limited to what's supported by the host operating system. Windows doesn't have anything like hard or symbolic links. I suspect that you're trying to do this so that you can edit instance files out of the shared directory with host tools. You might be able to pull this off by installing to non-shared files, then copying the critical parts (like the src directory if you're doing this for development purposes) to a host directory, and then (and only then) establishing that existing host directory as a shared directory. If you try it, let us know how it works!
0
419
false
0
1
Can't Install Plone on VirtualBox Shared Folder because Python Fails to Install
10,527,263
2
2
0
0
2
1
0
0
I'm running Windows 7 64bit as my Host OS and Debian AMD64 as my Guest OS. On my Windows machine a folder called www is mounted on Debian under /home/me/www. I have no problem installing Plone on Debian (the guest OS) with the unified installer. However, when I try to change the default install path from /home/me/Plone to /home/me/www/plone, the installation always fails because Python fails to install. In the install.log it says ln: failed to create hard link 'python' => 'python2.6': Operation not permitted It looks like it might have something to do with access permissions, but I have tried to run the install script either using sudo or as a normal user, none of it helps. The script installs fine elsewhere, just not in the shared folder in Virtualbox. Any suggestions? More Information: I don't have a root account on Debian (testing, System Python version is 2.7) and always use sudo.
0
python,debian,plone,virtualbox,zope
2012-05-09T21:47:00.000
1
10,524,564
How about using Debian's mount --bind to mount specific Host folders to portions of the installation tree?
0
419
false
0
1
Can't Install Plone on VirtualBox Shared Folder because Python Fails to Install
10,543,865
2
2
0
2
1
1
1.2
0
I just started looking into ctypes and was a little curious on how they work. How does it compare speed wise to the regular C implementation? Will using ctypes in a python program speed it up or slow it down is basically what I am wondering. Thanks!
0
python,python-2.7,ctypes
2012-05-11T00:46:00.000
0
10,543,992
there is no "regular C implementation" in most cases. Python data structures are one to three order of magnitudes higher level. To answer you question "how fast are ctypes in python?" - the answer is "pretty fast". look at numpy for an idea of it.
0
1,191
true
0
1
How fast are ctypes in python?
10,544,224
2
2
0
-1
1
1
-0.099668
0
I just started looking into ctypes and was a little curious on how they work. How does it compare speed wise to the regular C implementation? Will using ctypes in a python program speed it up or slow it down is basically what I am wondering. Thanks!
0
python,python-2.7,ctypes
2012-05-11T00:46:00.000
0
10,543,992
If speed is only concern don't use Python, PHP, Perl or other scripting language. Write whatever in C or Assembly. Since these scripting languages are fast enough to build Google, Facebook and Amazon, you will find that they are fast enough for whatever you are thinking about.
0
1,191
false
0
1
How fast are ctypes in python?
10,544,690
1
3
0
1
1
0
0.066568
0
I have a python CGI script which takes form input x andy (integers) and passes it to a C++ executable using subprocess in which the program writes the sum of the two values to a text file. The code works fine on my local machine. However, after much testing ,I found that whenever I run this program on my server (in /var/www) and attempt to write the file some kind of error occurs because I get the "Internal Server Error" page. The server is not mine and so I do not actually have sudo privileges. But from putty, I can manually run the executable, and it indeed writes the file. My guess is I have to somehow run the executable from the python script with some amount of permission, but I'm not sure. I would appreciate any suggestions! EDIT: @gnibbler: Interesting, I was able to write the file to the /tmp directory with no problem. So I think your suggestions are correct and the server simply won't allow me to write when calling the script from the browser. Also, I cannot access the directory with the error logs, so I will have try to get permission for that.
0
python,linux,cgi,subprocess
2012-05-11T11:56:00.000
1
10,550,858
Either the environment is different (maybe it's trying to write to the wrong dir) or more likely, the cgi isn't running as the same user that you are logging in as. For example, it's fairly common for cgi scripts to be executed as "nobody" or "www" etc. You could try getting the cgi to write a file into /tmp. That should at least confirm the user the cgi is running as
0
1,569
false
0
1
Unable to write to file programmatically on linux server
10,550,999
1
1
0
1
1
0
0.197375
1
I'm writing a script, to help me do some repetitive testing of a bunch of URLs. I've written a python method in the script that it opens up the URL and sends a get request. I'm using Requests: HTTP for Humans -http://docs.python-requests.org/en/latest/- api to handle the http calls. There's the request.history that returns a list of status codes of the directs. I need to be able to access the particular redirects for those list of 301s. There doesn't seem to be a way to do this - to access and trace what my URLS are redirecting to. I want to be able to access the redirected URLS (status code 301) Can anyone offer any advice? Thanks
0
python,module,urllib2,httplib
2012-05-12T00:10:00.000
0
10,560,005
Okay, I'm so silly. Here's the answer I was looking for r = requests.get("http://someurl") r.history[1].url will return the URL
0
1,706
false
0
1
Python trace URL get requests - using python script
10,569,571
1
1
0
1
2
1
1.2
0
I wanted to change interpreter to IronPython in Visual Studio 2010 with Python Tools for Visual Studio. Last time I hadn't problems with this I got CPython and IronPython on list but now IronPython magically disappeared. After this I tried to restore it and done this: I reinstalled PTVS, this still didn't helped I reinstalled IronPython in system and still nothing So I thought to add this entry manual but I don't know what should I enter there. I can still create project in IronPython and IntelliSense properly suggest me assembles. Could you show me how to force PTVS to rescan to look for IronPython or what should I enter to add this entry manually.
0
visual-studio-2010,visual-studio,ironpython,ptvs
2012-05-12T22:09:00.000
0
10,567,766
You probably are running the latest version of IronPython and re-installed PTVS. PTVS currently installs IronPython support conditionally on whether or not it detects that IronPython is installed. Something changed in the latest version of IronPython and the PTVS installer fails to detect that IronPython is installed. The good news is you can manually select to install IronPython support. First un-install, then start the installer and on the very first screen there's an Advanced button. Click on that and when the feature tree comes up change IronPython support to be installed. We've changed this for 1.5 so we'll always install IronPython support by default, so in the future this won't be an issue.
0
853
true
0
1
PTVS doesn't detect IronPython installation
10,568,603
2
2
0
1
1
1
0.099668
0
Ok, I recently installed Python27 with macports, but something happened and I created a mess. So I uninstalled it with sudo port uninstall --follow-dependents python27. Then I reinstalled it, did sudo port select --set python python27. All successful up to this point. But now I go to run python, and I get an error: ImportError: No module named site Any ideas? It's been driving me crazy for the past hour. Mac OS X Lion / Python 2.7 / MacPorts
0
python,macports
2012-05-13T23:55:00.000
0
10,576,151
The proper solution for this problem was to make it sure your PYTHONHOME environment variable is set correctly. You will receive this error if PYTHONHOME is pointing to invalid location or to another Python installation you are trying to run.
0
3,480
false
0
1
ImportError: No module named site - Python27 - MacPorts
12,093,366
2
2
0
0
1
1
0
0
Ok, I recently installed Python27 with macports, but something happened and I created a mess. So I uninstalled it with sudo port uninstall --follow-dependents python27. Then I reinstalled it, did sudo port select --set python python27. All successful up to this point. But now I go to run python, and I get an error: ImportError: No module named site Any ideas? It's been driving me crazy for the past hour. Mac OS X Lion / Python 2.7 / MacPorts
0
python,macports
2012-05-13T23:55:00.000
0
10,576,151
I had this problem and in the end it turned out to be to do with permissions. Stupid mac-ports did something, not quite sure what, but I applied sudo chmod -R a+x $PYTHONPATH (which basically makes all files beneath $PYTHONPATH executable by everyone). It's a nasty, and perhaps dangerous fix from a security perspective, but at this stage I just want to get it to work!
0
3,480
false
0
1
ImportError: No module named site - Python27 - MacPorts
25,899,137
1
2
0
2
10
0
0.197375
0
I would like to use an expect-like module in python3. As far as I know, neither pexpect nor fabric work with python3. Is there any similar package I can use? (If no, does anyone know if py3 support is on any project's roadmap?) A perfectly overlapping feature set isn't necessary. I don't think my use case is necessary here, but I'm basically reimplementing a Linux expect script that does a telnet with some config-supplied commands, but extending functionality.
0
python,python-3.x,expect,fabric,pexpect
2012-05-15T15:04:00.000
0
10,603,596
Happily, pexpect now supports python 3 (as of 2013 if not earlier). It appears that @ThomasK has been able to add his pexpect-u Python 3 functionality (with some API changes) back into the main project. (Thanks Thomas!)
0
1,916
false
0
1
Is there an implementation of 'expect' or an expect-like library that works in python3?
23,901,161
1
1
0
1
0
0
0.197375
0
I have made a python ladon webservice and I run is on Ubuntu with Apache2 and mod_wsgi. (I use Python 2.6). The webservice connect to a postgreSQL database with psycopg2 python module. My problem is that the psycopg2.connection is closed (or destroyed) automatically after a little time (after about 1 or 2 minutes). The other hand if I run the server with ladon2.6ctl testserve command (http://ladonize.org/index.php/Python_Configuration) than the server is working and the connection is not closed automatically. I can't understand why the connection is closed with apache+mod_wsgi and in this case the webserver is very slowly. Can anyone help me?
1
python,web-services,apache2,mod-wsgi,psycopg2
2012-05-17T13:12:00.000
0
10,636,409
If you are using mod_wsgi in embedded moe, especially with preform MPM for Apache, then likely that Apache is killing off the idle processes. Try using mod_wsgi daemon mode, which keeps process persistent and see if it makes a difference.
0
450
false
1
1
Python psycopg2 + mod_wsgi: connection is very slow and automatically close
10,645,670
1
3
0
4
20
0
0.26052
0
I've built a paywalled CMS + invoicing system for a client and I need to get more stringent with my testing. I keep all my data in a Django ORM and have a bunch of Celery tasks that run at different intervals that makes sure that new invoices and invoice reminders get sent and cuts of access when users don't pay their invoices. For example I'd like to be a able to run a test that: Creates a new user and generates an invoice for X days of access to the site Simulates the passing of X + 1 days, and runs all the tasks I've got set up in Celery. Checks that a new invoice for an other X days has been issued to the user. The KISS approach I've come up with so far is to do all the testing on a separate machine and actually manipulate the date/time at the OS-level. So the testing script would: Set the system date to day 1 Create a new user and generate the first invoice for X days of access Advance then system date 1 day. Run all my celery tasks. Repeat until X + 1 days have "passed" Check that a new invoice has been issued It's a bit clunky but I think it might work. Any other ideas on how to get it done?
0
python,testing,mocking,integration-testing,celery
2012-05-18T11:48:00.000
1
10,652,097
Without the use of a special mock library, I propose to prepare the code for being in mock-up-mode (probably by a global variable). In mock-up-mode instead of calling the normal time-function (like time.time() or whatever) you could call a mock-up time-function which returns whatever you need in your special case. I would vote down for changing the system time. That does not seem like a unit test but rather like a functional test as it cannot be done in parallel to anything else on that machine.
0
3,901
false
1
1
Simulating the passing of time in unittesting
10,653,559
1
1
0
1
2
0
1.2
0
I want to generate an Eclipse plugin that just runs an existing Python script with parameters. While this sounds very simple, I don't think it's easy to implement. I can generate a Eclipse plugin. My issue is not how to use PDE. But: can I call the existing Python script from Java, from an Eclipse plugin? it needs to run from the embedded console with some parameters Is this reasonably easy to do? And I don't plan to reimplement it in any way. Calling it from command-line works very well. My question is: can Eclipse perform this, too? Best, Marius
0
python,eclipse-plugin,eclipse-pde
2012-05-19T13:55:00.000
1
10,665,768
You can already create an External Launch config from Run>External Tools>External Tools Configurations. You are basically calling the program from eclipse. Any output should then show up in the eclipse Console view. External launch configs can also be turned into External Builders and attached to projects. If you are looking to run your python script within your JVM then you need a implementation of python in java ... is that what you are looking for?
0
1,884
true
1
1
Eclipse plugin that just runs a python script
10,856,306
1
2
0
0
1
0
0
0
I use Tornado as the web server. I write some daemons with Python, which run in the server hardware. Sometimes the web server needs to send some data to the daemon and receives some computed results. There are two working: 1. Asynchronous mode: the server sends some data to the daemons, and it doesn't need the results soon. Can I use message queue to do it perfectly? 2. Synchronous mode: the server sends data to the daemons, and it will wait until it get the results. Should Iuse sockets? So what's the best way of communication between tornado and Python based daemon?
0
python,sockets,tornado
2012-05-19T16:15:00.000
1
10,666,877
Depending on the scale - the simple thing is to just use HTTP and the AsyncHTTPClient in Tornado. For the request<->response case in our application we're going 300 connections/second with such an approach. For the first case Fire and forget, you could also use AsyncHTTP and just have the server close out the connection and continue working...
0
732
false
0
1
What's the best way of communication between tornado and Python based daemon?
10,667,711
1
2
0
0
0
1
0
0
I'm using isotoma.buildout.autodevelop to develop eggs which I'm currently developing within my buildout. I would like to include these developed eggs (which are located on the filesystem next to my buildout.cfg) as namespaces in my buildout's custom interpreter. Can anyone provide an example of this or link to some resource ?
0
python,buildout
2012-05-19T23:05:00.000
1
10,669,497
A) The mr.developer recipe mentioned on your recipe's page is probably a better choice. B) you want your eggs in bin/python? Include them in 'eggs' in your zc.recipe.eggs part in your buildout where you generate bin/python.
0
143
false
0
1
Including a locally developed python package in a buildout interpreter
10,678,298
4
5
0
1
3
0
0.039979
0
I'm attempting to get eclipse running as something more powerful than a colored text editor so that I can do some Maya scripting. There's literally nothing fancy about this setup, it just doesn't keep my interpreter once the prefs window is closed. I can open and view .py docs fine, but pydev will not keep the interpreter I give it. As soon as I save the prefs with vanilla python.exe chosen as the interpreter, eclipse loses it. Opening the prefs again will show a blank interpreter page. Auto config used to work before I started mucking with settings. I had the same disappearing problem even though Autoconfig could find everything. c:\Python27 is set in my PYTHONPATH for user and system variables. I've tried 32 and 64bit python (running win7 64). I was using Aptana with pydev and it seemed to not complain for a while, but then the interpreter went awol and I tried Eclipse to fix it. I can't start an actual project due to the missing interpreter, and the large "help" box that pops up when I'm typing is slowing me down considerably. Eclipse 3.7.2 Python 2.7.2 Pydev 2.5 Thanks for your help, I'm pretty green at this.
0
python,eclipse,installation,pydev,interpreter
2012-05-20T03:27:00.000
1
10,670,576
I've been wresting with this problem all evening and just now solved it for me. My problem was with a workspace saved in Google Drive, but where Drive had created a lot of files with a (1) before the first period in the .metadata folder, presumably as a conflict resolution thing. Using File Commander (the search in Windows 7 ignored the parenthesis ?!) I searched for all the files containing (1) and delted them. (It should be said I made a copy of the folder first and opened it as a workspace to experiment on, as I've never figured out how to import a project once the workspace is lost.) In my case, it worked like a charm. Now I'm going to be very nervous about having Eclipse open on both coding machines at once. We'll see how it goes from here.
0
2,628
false
0
1
Eclipse + Pydev wont keep interpreter setting within the same session.
20,319,027
4
5
0
0
3
0
0
0
I'm attempting to get eclipse running as something more powerful than a colored text editor so that I can do some Maya scripting. There's literally nothing fancy about this setup, it just doesn't keep my interpreter once the prefs window is closed. I can open and view .py docs fine, but pydev will not keep the interpreter I give it. As soon as I save the prefs with vanilla python.exe chosen as the interpreter, eclipse loses it. Opening the prefs again will show a blank interpreter page. Auto config used to work before I started mucking with settings. I had the same disappearing problem even though Autoconfig could find everything. c:\Python27 is set in my PYTHONPATH for user and system variables. I've tried 32 and 64bit python (running win7 64). I was using Aptana with pydev and it seemed to not complain for a while, but then the interpreter went awol and I tried Eclipse to fix it. I can't start an actual project due to the missing interpreter, and the large "help" box that pops up when I'm typing is slowing me down considerably. Eclipse 3.7.2 Python 2.7.2 Pydev 2.5 Thanks for your help, I'm pretty green at this.
0
python,eclipse,installation,pydev,interpreter
2012-05-20T03:27:00.000
1
10,670,576
I had the same problem in fedora, disappearing interpreter settings. The issue was Eclipse couldn't write to the folder even after granting read+write access. Solution: Go to terminal and type: sudo eclipse enter admin password to run as admin. Solved
0
2,628
false
0
1
Eclipse + Pydev wont keep interpreter setting within the same session.
24,027,445
4
5
0
1
3
0
0.039979
0
I'm attempting to get eclipse running as something more powerful than a colored text editor so that I can do some Maya scripting. There's literally nothing fancy about this setup, it just doesn't keep my interpreter once the prefs window is closed. I can open and view .py docs fine, but pydev will not keep the interpreter I give it. As soon as I save the prefs with vanilla python.exe chosen as the interpreter, eclipse loses it. Opening the prefs again will show a blank interpreter page. Auto config used to work before I started mucking with settings. I had the same disappearing problem even though Autoconfig could find everything. c:\Python27 is set in my PYTHONPATH for user and system variables. I've tried 32 and 64bit python (running win7 64). I was using Aptana with pydev and it seemed to not complain for a while, but then the interpreter went awol and I tried Eclipse to fix it. I can't start an actual project due to the missing interpreter, and the large "help" box that pops up when I'm typing is slowing me down considerably. Eclipse 3.7.2 Python 2.7.2 Pydev 2.5 Thanks for your help, I'm pretty green at this.
0
python,eclipse,installation,pydev,interpreter
2012-05-20T03:27:00.000
1
10,670,576
I had the same issue. This is how I solved it: Go to your workspace folder. Edit the file ".pydevproject". Change the path located after "PYTHON_PROJECT_INTERPRETER" pydev property. Save and you're good to go.
0
2,628
false
0
1
Eclipse + Pydev wont keep interpreter setting within the same session.
27,167,729
4
5
0
1
3
0
0.039979
0
I'm attempting to get eclipse running as something more powerful than a colored text editor so that I can do some Maya scripting. There's literally nothing fancy about this setup, it just doesn't keep my interpreter once the prefs window is closed. I can open and view .py docs fine, but pydev will not keep the interpreter I give it. As soon as I save the prefs with vanilla python.exe chosen as the interpreter, eclipse loses it. Opening the prefs again will show a blank interpreter page. Auto config used to work before I started mucking with settings. I had the same disappearing problem even though Autoconfig could find everything. c:\Python27 is set in my PYTHONPATH for user and system variables. I've tried 32 and 64bit python (running win7 64). I was using Aptana with pydev and it seemed to not complain for a while, but then the interpreter went awol and I tried Eclipse to fix it. I can't start an actual project due to the missing interpreter, and the large "help" box that pops up when I'm typing is slowing me down considerably. Eclipse 3.7.2 Python 2.7.2 Pydev 2.5 Thanks for your help, I'm pretty green at this.
0
python,eclipse,installation,pydev,interpreter
2012-05-20T03:27:00.000
1
10,670,576
I encountered this problem, and the issue was that .project and .pydevproject were read only and Eclipse couldn't save the configurations. Solution: make .project and .pydevproject writable.
0
2,628
false
0
1
Eclipse + Pydev wont keep interpreter setting within the same session.
56,161,921
1
1
0
0
1
0
1.2
0
I'm writing an web app. Users can post text, and I need to store them in my DB as well as sync them to a twitter account. The problem is that I'd like to response to the user immediately after inserting the message to DB, and run the "sync to twitter" process in background. How could I do that? Thanks
0
python
2012-05-20T12:06:00.000
0
10,673,245
either you choose zrxq's solution, or you can do that with a thread, if you take care of two things: you don't tamper with objects from the main thread (be careful of iterators), you take good care of killing your thread once the job is done. something that would look like : import threading class TwitterThreadQueue(threading.Thread): queue = [] def run(self): while len(self.queue!=0): post_on_twitter(self.queue.pop()) # here is your code to post on twitter def add_to_queue(self,msg): self.queue.append(msg) and then you instanciate it in your code : tweetQueue = TwitterThreadQueue() # ... tweetQueue.add_to_queue(message) tweetQueue.start() # you can check if it's not already started # ...
0
56
true
1
1
Sync message to twitter in background in a web application
10,674,012
1
1
0
1
1
1
1.2
0
I have a python program I wrote that I am trying to "compile" with py2exe, everything goes well and the executable is created. The first time I run the program I get this error: Traceback (most recent call last): File "IMGui.py", line 13, in ImportError: No module named IMCrypt2 I found that if I manually add my custom modules to /lib/shared.zip and run the program again, I get THIS error: Traceback (most recent call last): File "IMGui.py", line 13, in zipimport.ZipImportError: can't find module 'IMCrypt2' I have been doing some extensive googling, 2 solutions I've found on the web were to delete the 'dist' and 'build' folders and try again, and to add "includes":"decimal" to my options, but neither of these solutions have worked for me D= I'm using python 2.5 (I was using new version, but building with those were giving me other strange runtime errors, and the version I did successfully build on Windows 7 ONLY worked on Windows 7, so I'm trying again using Python 2.5 on Windows XP in an attempt to get a more 'universal' windows executable) I'm completely stumped! Any help would be greatly appreciated!
0
python,py2exe
2012-05-21T06:59:00.000
0
10,680,724
I solved my own problem (kinda), I was able to avoid this error and successfully 'compile' my code by consolidating all my modules in to a single file, so that no custom modules were imported. It resulted in some super messy code, but it worked!
0
2,876
true
0
1
zipimport.ZipImportError: can't find module from program made with py2exe
10,716,585
2
3
0
3
8
1
0.197375
0
I am newbie in cryptography and pycrypto. I have modulus n and private exponent d. From what I understand after reading some docs private key consists of n and d. I need to sign a message and I can't figure out how to do that using pycrypto. RSA.construct() method accepts a tuple. But I have to additionally provide public exponent e to this method (which I don't have). So here is my question. Do I have to compute e somehow in order to sign a message? It seems I should be able to sign a message just by using n and d (that constitute private key). Am I correct? Can I do this with pycrypto? Thanks in advance.
0
python,cryptography,rsa,pycrypto
2012-05-21T16:49:00.000
0
10,689,273
No, you can't compute e from d. RSA is symmetric in d and e: you can equally-well interchange the roles of the public and the private keys. Of course, we choose one specially to be private and reveal the other -- but theoretically they do the same thing. Naturally, since you can't deduce the private key from the public, you can't deduce the public key from the private either. Of course, if you have the private key that means that you generated the keypair, which means that you have the public key somewhere.
0
10,098
false
0
1
I have modulus and private exponent. How to construct RSA private key and sign a message?
10,689,441
2
3
0
2
8
1
0.132549
0
I am newbie in cryptography and pycrypto. I have modulus n and private exponent d. From what I understand after reading some docs private key consists of n and d. I need to sign a message and I can't figure out how to do that using pycrypto. RSA.construct() method accepts a tuple. But I have to additionally provide public exponent e to this method (which I don't have). So here is my question. Do I have to compute e somehow in order to sign a message? It seems I should be able to sign a message just by using n and d (that constitute private key). Am I correct? Can I do this with pycrypto? Thanks in advance.
0
python,cryptography,rsa,pycrypto
2012-05-21T16:49:00.000
0
10,689,273
If you don't have the public exponent you may be able to guess it. Most of the time it's not a random prime but a static value. Try the values 65537 (hex 0x010001, the fourth number of Fermat), 3, 5, 7, 13 and 17 (in that order). [EDIT] Simply sign with the private key and verify with the public key to see if the public key is correct. Note: if it is the random prime it is as hard to find as the private exponent; which means you would be trying to break RSA - not likely for any key sizes > 512 bits.
0
10,098
false
0
1
I have modulus and private exponent. How to construct RSA private key and sign a message?
10,690,482
1
2
0
1
2
0
1.2
0
When developing macros in python for LibreOffice / OpenOffice on Linux at least, I've read that you have to place your py scripts in a particular directory. Is there a preferred method among Python LibreOffice/OOo developers for deploying these scripts, or is there another way to specify within LibreOffice/OOo to specify where you want these scripts to be?
0
python,openoffice.org,libreoffice
2012-05-24T17:10:00.000
1
10,742,188
Maybe a nice way to go is to get familiarized with Python setup tools itself (http://packages.python.org/an_example_pypi_project/setuptools.html), and write a proper setup.py script which would place all needed files in the appropriate dirs. Your macros could them even be installable with the "easy_install" Python framework
0
733
true
0
1
Preferred method of "deploying" python scripts to LibreOffice during macro development?
10,743,591
1
3
0
2
1
0
0.132549
0
I have this python script that outputs the Twitter Stream to my terminal console. Now here is the interesting thing: * On snowleopard I get all the data I want. * On Ubuntu (my pc) this data is limited and older data is deleted. Both terminal consoles operate in Bash, so it has to be an OS thing presumably. My question is: how do I turn this off? I want to leave my computer on for a week to capture around 1 or 2 gigabytes of data, for my bachelor thesis!
0
python,linux,ubuntu,console,terminal
2012-05-24T21:13:00.000
1
10,745,363
I'd also avoid doing this with a terminal, but to answer the question directly: right click on the terminal window profiles profile preferences scolling scollback: unlimited It's better though to redirect to a file, then access that file. "tail -f" is very helpful.
0
957
false
0
1
Ubuntu Linux: terminal limits the output when I get the full Twitter Streaming API
10,745,449
2
3
0
1
0
1
0.066568
0
I basically want to read a file (could be an mp3 file or whatever). Scan the file for all the used ASCII characters of the file and put them into an dictionary, array or list. And then from there assign each character a number value. For example: Let's say I load in the file blabla.mp3 (Obviously this type of file is encoded so it won't be just plain english characters.) This is it's contents: ╤dìúúH»╓╒:φººMQ╤╤╤╤┤i↔↔←GGGΦ⌠i←E::2E┤tti←╙╤ΦΦ⌠·:::::%Fæ╤╤:6Å⌠tSN│èëåD¿╢ÄÄÄÄÄÄÄÄÅO^↔:::.ÄÄÄÄÄÄèHΦΦ■ï»ó⌐╙-↔→E┤tttttttt}▲î╤╤dì"Ü:::)ú$tm‼º╤╓q╤╙·:.ñǰ"V├╡ΦPa↨/úúúúúúΦ╞îHΦ║*ÄèúóΦΦΦΦ»DΦΦ·tΘ○_Nïúkî►"DëÜ)#ú»→·:4Äïúúúúúó¿║:(  ·:ç↑PR"$RGH◄◘úúó¿ΦΦΦΦ┌&HΦΦ┌+⌠WºGG ╤m→GF╘±"¿ΦñïúúúóΦò↨FæTtt╓ìú⌠ΦΦΦ⌠z:::=:::::≥E╤╤╤╤╤╤╤Tm↔↔▬Hªèi⌠ztz:::tt I want to figure out what characters are being used and assign each one a value from 0 - 255 and each value will be unique to that character. So ╤ = 0; Φ = 56; ú = 25 etc etc etc Now I've been searching the python and java docs and I'm not so sure I know what I'm searching for. And I don't know if I should be worrying about ASCII characters or HEX or the raw bytes of the file. I just need someone to point me in the right direction. Any help?
0
java,python
2012-05-25T03:12:00.000
0
10,748,021
Each byte is a number from 0 to 255. An array containing those numbers is, precisely, an array containing the contents of the file. I'm not at all clear on what you want to do with this array (or dictionary, etc) but making it is going to be easy.
0
417
false
1
1
How can I bring all the used ASCII characters of a file into a dictionary/array/list and assign each character a value?
10,748,050
2
3
0
0
0
1
0
0
I basically want to read a file (could be an mp3 file or whatever). Scan the file for all the used ASCII characters of the file and put them into an dictionary, array or list. And then from there assign each character a number value. For example: Let's say I load in the file blabla.mp3 (Obviously this type of file is encoded so it won't be just plain english characters.) This is it's contents: ╤dìúúH»╓╒:φººMQ╤╤╤╤┤i↔↔←GGGΦ⌠i←E::2E┤tti←╙╤ΦΦ⌠·:::::%Fæ╤╤:6Å⌠tSN│èëåD¿╢ÄÄÄÄÄÄÄÄÅO^↔:::.ÄÄÄÄÄÄèHΦΦ■ï»ó⌐╙-↔→E┤tttttttt}▲î╤╤dì"Ü:::)ú$tm‼º╤╓q╤╙·:.ñǰ"V├╡ΦPa↨/úúúúúúΦ╞îHΦ║*ÄèúóΦΦΦΦ»DΦΦ·tΘ○_Nïúkî►"DëÜ)#ú»→·:4Äïúúúúúó¿║:(  ·:ç↑PR"$RGH◄◘úúó¿ΦΦΦΦ┌&HΦΦ┌+⌠WºGG ╤m→GF╘±"¿ΦñïúúúóΦò↨FæTtt╓ìú⌠ΦΦΦ⌠z:::=:::::≥E╤╤╤╤╤╤╤Tm↔↔▬Hªèi⌠ztz:::tt I want to figure out what characters are being used and assign each one a value from 0 - 255 and each value will be unique to that character. So ╤ = 0; Φ = 56; ú = 25 etc etc etc Now I've been searching the python and java docs and I'm not so sure I know what I'm searching for. And I don't know if I should be worrying about ASCII characters or HEX or the raw bytes of the file. I just need someone to point me in the right direction. Any help?
0
java,python
2012-05-25T03:12:00.000
0
10,748,021
Each byte you read in already is a value between 0 and 255 (thus a byte). Is there a reason you can't just use that?
0
417
false
1
1
How can I bring all the used ASCII characters of a file into a dictionary/array/list and assign each character a value?
10,748,060
1
1
0
0
0
1
0
0
I have downloaded the omniORB4.1.6 pre-compiled with msvc10. I have python 2.7 and everything seems to work fine. I want to know how i can tell my omniidl to use my python 2.6 installation instead of 2.7. Can anyone help me? Thanks.
0
python,python-2.7,omniorb
2012-05-25T20:27:00.000
0
10,760,968
you can't and shouldn't. it is compiled specifically for 2.7. that's why "2.7" appears in the download file name. if you want to use a different python, download the source package and build it yourself.
0
123
false
0
1
Changing python from 2.7 to 2.6 for omniidl
10,761,033
1
2
0
55
46
0
1
0
Is it possible to execute python commands passed as strings using python -c? can someone give an example.
0
python
2012-05-26T18:01:00.000
1
10,768,584
You can use -c to get Python to execute a string. For example: python3 -c "print(5)" However, there doesn't seem to be a way to use escape characters (e.g. \n). So, if you need them, use a pipe from echo -e or printf instead. For example: $ printf "import sys\nprint(sys.path)" | python3
0
42,043
false
0
1
Execute python commands passed as strings in command line using python -c
30,690,444
1
1
0
0
0
0
0
0
I have written cgi script for the login page in python but I am not familiar with running the CGI script?Please help me by giving the steps to run the script?
0
python-3.x
2012-05-28T09:04:00.000
0
10,781,998
Ask your Web host: 1) for a simple "hello, world" script (in Python, I assume) that will work on their server 2) where you need to store the file (in the server file system) 3) what you need to name it (ex: index.py or .py or whatever) 4) what permissions the script file needs to have (ask them for a "setfacl" command you can use), and 5) what the URL will be that calls it If any one of those things is even slightly wrong, your script will fail to run. If you get them all right, then your CGI script will return a "Hello, world" web page. At that point, you modify your script a little bit at a time, testing it every step of the way, until it is doing what you want it to do.
0
122
false
0
1
Running the CGI script
10,809,754
1
2
0
5
1
1
0.462117
0
If I import a module1.py from the python command line in windows 7 I see the corresponding module1.pyc file appear in the Python32/pycache/ folder. My understanding was that it is this bytecode which is executed by the Python interpreter, however I can delete the module1.pyc file and my module functions (module1.func1() etc...) can still be called from the command line. What is running when the functions are called but the .pyc file is not there? When the bytecode is compiled is it also copied to runtime memory for the Python shell?
0
python,bytecode
2012-05-28T13:00:00.000
0
10,785,105
The bytecode is in memory while running the interpreter. The .pyc files are a cache for the next import of the code, so that python will not have to parse the code if it has not changed.
0
905
false
0
1
How does Python run module code when there's no matching .pyc file?
10,785,135
1
2
0
21
14
1
1.2
0
What is the difference between calling sys.exit() and throwing an exception in Python? Let's say I have a Python script which does the following: open a file read lines close it If the file doesn't exist or an IOException gets thrown at runtime, which of the options below makes more sense? no except/catch of the exception, if exception occurs, it fails out (which is expected behaviour anyway) except/catch the exception, logs the error message, throw customized exception by myself, fails out. in an except IOException block, exit with an error message e.g. sys.exit("something is wrong") Does option 3 kill the process while 1 and 2 do not? What's the best way to handle the Python exceptions given that Python doesn't have a checked exception like Java (I am really a Java developer ^_^)?
0
python,exception-handling
2012-05-29T09:56:00.000
0
10,796,821
sys.exit raises a SystemExit itself so from a purely technical point of view there's no difference between raising that exception yourself or using sys.exit. And yes you can catch SystemExit exceptions like any other exception and ignore it. So it's just a matter of documenting your intent better. PS: Note that this also means that sys.exit is actually a pretty bad misnomer - because if you use sys.exit in a thread only the thread is terminated and nothing else. That can be pretty annoying, yes.
0
8,832
true
0
1
Difference between calling sys.exit() and throwing exception
10,796,924
1
3
0
2
0
1
0.132549
0
I'm going to be building web pages and web interfaces. So far I have been using LAMP stack with PHP. I want to shift to python. Which of the two Python versions (2.7 or 3.1) is better for this use?
0
python,python-3.x,lamp,python-2.x
2012-05-30T06:36:00.000
0
10,811,112
mod_wsgi didn't really work with 3.x until 3.2, so I'd stick with 2.7 for now.
0
670
false
0
1
Python 2.7 or 3.0 for LAMP
10,811,163
1
2
0
0
10
0
0
0
I'm running Python 3.2 on Win XP. I run a python script thru a batch file via this: C:\Python32\python.exe test.py %1 %1 is an argument that i pass to do some processing in the python script. I have 2 variables in the batch file that I also want to send as arguments to the python script. set $1=hey_hi_hello set $2=hey_hi I want to be able to do something like this if possible: C:\Python32\python.exe test.py %1 $1 $2 And then retrieve these argiments in the python script via sys.argv[2] and sys.argv[3] Would appreciate any help with this. Thank you.
0
python,batch-file,windows-xp
2012-05-30T19:34:00.000
1
10,823,033
Another option is to write arguments right after the python script, following the example: python your_script.py this that If you are using Linux .sh file, remember to run dos2unix XXX.sh before you run: bash XXX.sh. The reason, in a simple version, is that dos and unix use different newline breakers.
0
45,693
false
0
1
Sending arguments from Batch file to Python script
69,202,173
1
2
0
3
1
0
1.2
0
I'm working with an application where just about every module and every class emits logging messages. I need a way to capture every single one of those messages without explicitly attaching a handler via .addHandler() to each logging instance (which is what I'm doing right now). Is there any way to attach a handler to every logging instance at once?
0
python,logging
2012-05-31T05:09:00.000
0
10,827,751
logging uses a hierarchy of loggers. Add a handler to the root logger and it will receive logged messages from child loggers, too. To access the root logger use logging.getLogger().
0
1,549
true
1
1
Intercepting all logging messages
10,827,794
1
3
0
3
5
1
1.2
0
I currently develop an application which is written in C++. For scripting purposes I use Python 3.2, which is fine -- on my developer machine with Python installed and all the DLLs in the right place. I deployed "pure" Python applications (i.e. without native code) before using the excellent py2exe, but I don't have a first clue how to deploy this with an embedded Python. From what my gut says I suppose the following components are necessary: Python3.dll & Python32.dll The .pyd files from Python's "DLLs" directory The Python library And the last point is what bothers me: How do I deploy that? That are a few thousand files and I don't really want to copy that around. Py2exe packs that into a zip-file, I guess I can do something like that in my case too? And, even more important: How do I tell the Python interpreter at run-time where he finds the library?
0
c++,python,deployment,scripting,packaging
2012-05-31T15:07:00.000
0
10,836,259
From what I recall what you need to bundle depends on what your python scripts call or make use of. If you really only make use of the core intepreter I think you only need to bundle the dll. Having said that, it shouldn't be too hard to test this on your development box by disabling any paths to your installed python and putting your app and the python dlls and libs into the same test folder.
0
2,147
true
0
1
Deployment of application with embedded Python 3
10,839,045
1
2
0
0
2
0
0
0
I'm trying to get pylint to give html output when I run Validate syntax on a python file in TextMate. I installed pycheckmate, pylint, and created a .pylintrc file in $HOME that sets the output format to html. In TextMate's Advanced control panel, in the Shell Variables tab, I have TM_PYCHECKER set to /usr/local/share/python/pylint. If I trigger Validate Syntax, it runs pylint with all the default options, and gives me the output. If I change TM_PYCHECKER to /usr/local/share/python/pylint --rcfile "$HOME/.pylintrc" and Validate Syntax again, I get: Please install PyChecker, PyFlakes or Pylint for more extensive code checking. If I run /usr/local/share/python/pylint from the commandline, without any arguments, the output is html, so I know in that case that it's reading the rcfile. What am I missing?
0
python,textmate,pylint
2012-05-31T15:24:00.000
0
10,836,517
A somewhat educated guess: try replacing $HOME by the absolute path to your home directory. Shell variables like $HOME are probably not available to use in TextMate's control panel. UPDATE: Looking at the pycheckmate.py script included with the Python.tmbundle included with the version of TextMate I have, it appears that it is not possible to include arguments , like --rcfile /path/to/rcfile. The value of TM_PYCHECKER is expected to only be the path to the checker binary with no arguments. But, if you make your own copy of the Python.tmbundle, you should be able to edit pycheckmate.py to do as you wish.
0
1,057
false
0
1
pylint ignores .pylintrc when run from TextMate
10,838,327
1
1
0
2
2
0
1.2
1
I want to display visual/auditory stimuli inside a web browser for psychophysic experiments. I plan on using python, but I am concerned with timing. I obviously can not rely on screen refresh for timing which is common in these types of tasks. How much can I hope for in terms of accuracy for timing on the web and what are the best tools to use with Python. I am thinking of using FastCGI I just want to hear peoples thoughts on this.
0
python,web,fastcgi,timing,psychtoolbox
2012-06-01T22:58:00.000
0
10,858,337
Do your timing in JS, save current time in ms on document.ready and then when user hits a key. Benchmark your test with either high-speed camera, or test rig that "hits" a key, e.g. screen flash -> pohototransistor -> usb device -> virtual keyboard
0
296
true
0
1
Achieving best timing online for psychophysics experiments using Python on the web
10,999,764
2
3
0
2
2
1
0.132549
0
I have an open source PHP website and I intend to modify/translate (mostly constant strings) it so it can be used by Japanese users. The original code is PHP+MySQL+Apache and written in English with charset=utf-8 I want to change, for example, the word "login" into Japanese counterpart "ログイン" etc I am not sure whether I have to save the PHP code in utf-8 format (just like Python)? I only have experience with Python, so what other issues I should take care of?
1
php,python,mysql,apache,utf-8
2012-06-03T06:52:00.000
0
10,868,473
If it's in the file, then yes, you will need to save the file as UTF-8. If it's is in the database, you do not need to save the PHP file as UTF-8. In PHP, strings are basically just binary blobs. You will need to save the file as UTF-8 so the correct bytes are read in. In theory, if you saved the raw bytes in an ANSI file, it would still be output to the browser correctly, just your editor would not display it correctly, and you would run the risk of your editor manipulating it incorrectly. Also, when handling non-ANSI strings, you'll need to be careful to use the multi-byte versions of string manipulation functions (str_replace will likely botch a utf-8 string for example).
0
148
false
0
1
PHP for Python Programmers: UTF-8 Issues
10,868,488
2
3
0
0
2
1
0
0
I have an open source PHP website and I intend to modify/translate (mostly constant strings) it so it can be used by Japanese users. The original code is PHP+MySQL+Apache and written in English with charset=utf-8 I want to change, for example, the word "login" into Japanese counterpart "ログイン" etc I am not sure whether I have to save the PHP code in utf-8 format (just like Python)? I only have experience with Python, so what other issues I should take care of?
1
php,python,mysql,apache,utf-8
2012-06-03T06:52:00.000
0
10,868,473
If the file contains UTF-8 characters then save it with UTF-8. Otherwise you can save it in any format. One thing you should be aware of is that the PHP interpreter does not support the UTF-8 byte order mark so make sure you save it without that.
0
148
false
0
1
PHP for Python Programmers: UTF-8 Issues
10,868,497
1
2
0
1
4
1
0.099668
1
What is the best solution in python, to monitor CPU, memory, and bandwidth usage per domain? This solution has to also work on multiple instances.
0
python,amazon-ec2,amazon-web-services,amazon-cloudwatch
2012-06-03T10:14:00.000
0
10,869,472
CPU can be monitored by CloudWatch using the built-in metrics. For memory you can use custom metrics with the AWS command line tools or write powershell/ruby scripts with the official AWS SDK. You can monitor anything that's easily quantifiable using the AWS SDK. To monitor bandwidth usage per domain I'd recommend something like ntop.
0
3,733
false
0
1
Monitor bandwidth, memory, cpu per domain on EC2
11,124,827
2
3
0
1
0
1
0.066568
0
I want to implement an RSA cryptosystem algorithm for a university project and I' m trying to decide which programming language to use. I am very familiar with C so it would be a convenient choice. However, the algorithm will have to deal with very large numbers (it will include a Primality subroutine), and I have heard that using Python will result in a better implementation. Is that right? Thank you in advance.
0
python,c,cryptography,rsa,primality-test
2012-06-03T14:32:00.000
0
10,871,163
I don't know if Python will result in a "better" implementation, since better is rather subjective here. You can find numerical libraries for both that will allow you to deal with large numbers easily. Python has the advantage (imo) of having the numpy library which is very easy to read and use and is generally more human readable which often leads to easier debugging.
0
1,059
false
0
1
Suitable Language for RSA implementation
10,871,183
2
3
0
0
0
1
0
0
I want to implement an RSA cryptosystem algorithm for a university project and I' m trying to decide which programming language to use. I am very familiar with C so it would be a convenient choice. However, the algorithm will have to deal with very large numbers (it will include a Primality subroutine), and I have heard that using Python will result in a better implementation. Is that right? Thank you in advance.
0
python,c,cryptography,rsa,primality-test
2012-06-03T14:32:00.000
0
10,871,163
Using a scripting language or any more high level language than C (e.g. C# or Java) will most likely be easier since you don't have to deal with memory management and other tasks not really related to your project.
0
1,059
false
0
1
Suitable Language for RSA implementation
10,871,180
1
4
0
83
56
1
1.2
0
I have read the documentation for this function, however, I dont think I understand it properly. If anyone can tell me what I'm missing, or if I am correct, it would be a great help. Here is my understanding: using the shutil.rmtree(path) function, it will delete only the directory specified, not the entire path. IE: shutil.rmtree('user/tester/noob') using this, it would only delete the 'noob' directory correct? not the complete path?
0
python,python-2.7,shutil
2012-06-03T19:40:00.000
0
10,873,364
If noob is a directory, the shutil.rmtree() function will delete noob and all files and subdirectories below it. That is, noob is the root of the tree to be removed.
0
91,285
true
0
1
shutil.rmtree() clarification
10,873,516
1
2
0
2
6
0
1.2
0
Background I have a Django application, it works and responds pretty well on low load, but on high load like 100 users/sec, it consumes 100% CPU and then due to lack of CPU slows down. Problem: Profiling the application gives me time taken by functions. This time increases on high load. Time consumed may be due to complex calculation or for waiting for CPU. So, how to find the CPU cycles consumed by a piece of code ? Since reducing the CPU consumption will increase the response time. I might have written extremely efficient code and need to add more CPU power OR I might have some stupid code taking the CPU and causing the slow down ? Update I am using Jmeter to profile my web app, it gives me a throughput of 2 requests/sec. [ 100 users] I get a average time of 36 seconds on 100 request vs 1.25 sec time on 1 request. More Info Configuration Nginx + Uwsgi with 4 workers No database used, using a responses from a REST API On 1st hit the response of REST API gets cached, therefore doesn't makes a difference. Using ujson for json parsing. Curious to know: Python-Django is used by so many orgs for so many big sites, then there must be some high end Debug / Memory-CPU analysis tools. All those I found were casual snippets of code that perform profiling.
0
python,django,performance,profiling,stress-testing
2012-06-04T06:16:00.000
0
10,877,048
You could try configuring your test to ramp up slowly, slow enough so that you can see the CPU gradually increase and then run the profiler before you hit high CPU. There's no point trying to profile code when the CPU is maxed out because at this point everything will be slow. In fact, you really only need a relatively light load to get useful data from a profiler. Also, by gradually increasing the load you will be better able to see if there is a gradual increase in CPU (suggesting a CPU bottleneck) or if there is a sudden jump in CPU (suggesting perhaps another type of problem, one that would not necessarily be addressed by more CPU). Try using something like a Cosntant Throughput Timer to pace the requests, this will prevent JMeter getting carried away and over-loading the system.
0
1,360
true
1
1
How do you find the CPU consumption for a piece of Python?
10,906,462
1
4
0
11
38
1
1
0
Is it possible to make a minimalistic operating system using Python? I really don't want to get into low-level code like assembly, so I want to use a simple language like Perl, Python. But how?
0
python,operating-system
2012-06-05T20:49:00.000
1
10,904,721
I suggest you find a good textbook on operating system design, and study that. I'm pretty sure you won't find such a book with Python source code; C is more likely. (You might find an older textbook that uses Pascal instead of C, but it's really not that different.) Once you have studied operating systems design enough to actually be able to write an operating system, you will know enough to have your own opinions on what languages would be suitable.
0
76,823
false
0
1
Is it possible to create an operating system using Python?
10,905,302
1
1
0
0
0
0
0
0
Newbie question I am finding it hard to get my head around. If I wanted to use one of the many tool out their like rsync lsync or s3cmd how can you build these into a program for none computer savvy people to use. Ie I am comfortable opening terminal and running s3cmd which Is developed in python how would I go about developing this as a dmg file for mac or exe file for windows? So a user could just install the dmg or exe then they have s3cmd lsync or rsync on their computer. I can open up eclipse code a simple app in java and then export as a dmg or exe I cannot figure out how you do this for other languages say write a simple piece of code that I cam save as a dmg or exe and that after installed will add a folder to my desktop or something simple like that to get me started?
0
python,exe,dmg
2012-06-05T23:01:00.000
1
10,906,198
If you mean specifically with Python, as I gather from tagging that in your question, it won't simply run the same way as Java will, because there's no equivalent Virtual Machine. If the user has a Python interpreter on their system, they they can simply run the .py file. If they do not, you can bundle the interpreter and needed libraries into an executable using Py2Exe, cxFreeze, or bbFreeze. For replacing a dmg, App2Exe does something similar. However. the three commands you listed are not python-related, and rely on functionality that is not necessarily available on Windows or Mac, so it might not be as possible.
0
1,925
false
1
1
Compiling and running code as dmg or exe
10,906,453
1
1
0
6
4
0
1
0
While trying to understand what problem does OSGI solve in the java ecosystem ,i find myself wondering if there is such a problem in python as well ? if yes how it is solved , if no why ?
0
java,python,osgi
2012-06-06T09:46:00.000
0
10,911,789
The purpose of OSGi is to write (reusable) active modules that can discover each other at runtime so that these modules can decide to collaborate. The primary mechanism is the service registry that acts as a simple broker for objects. A similar mechanism exists in JavaScript with the exports global variable. Unlike the JavaScript module systems, however, the OSGi service registry is dynamic. I am not aware of anything like this in Python. I think the need for something like OSGi arises in larger programs made with larger or diversified teams. An area that Java with its static typing is more suitable for. Especially since Java has a very strong focus on interface based design; in the eco system of Java/OSGi you find many specifications and actually multiple implementations. In this world, a broker that matches implementations to specifications is important. I think Python, and for that matter Ruby, and other languages would greatly benefit from a service broker like OSGi.
0
908
false
0
1
is there a requirement in python similar to what osgi tries to solve in java ?
10,928,722
1
2
0
3
2
0
0.291313
0
I have a small python script that creates a graph of data pulled from MySQL. I'm trying to figure out a way to run the script in the background all time on a regular basis. I've tried a number of things: A Cron Job that runs the script A loop timer Using the & command to run the script in the background These all have there pluses and minuses: The Cron Job running more then every half hour seems to eat up more resources then it's worth. The Loop timer put into the script doesn't actually put the script in the background it just keeps it running. The Linux & command backgrounds the process but unlike a real Linux service I can't restart/stop it without killing it. Can someone point me to a way to get the best out of all of these methods?
0
python,linux,service
2012-06-07T00:51:00.000
1
10,924,309
The cron job is probably a good approach in general, as the shell approach requires manual intervention to start it. A couple of suggestions: You could use a lock file to ensure that the cron job only ever starts one instance of the python script - often problems occur when using cron for larger jobs because it starts a second instance before the first instance has actually finished. You can do this simply by checking whether the lock file exists, then, if it does not, 'touch'ing the file at the beginning of the script and 'rm'ing it as your last action at the end of the script. If the lock file exists -- simply exit the script, as there is already one instance running. (Of course, if the script dies you will have to delete the lock file before running the script again). Also, if excessive resource use is a problem, you can ensure that the script does not eat too many resources by giving it a low priority (prefix with, for example, nice -n 19).
0
7,997
false
0
1
How can I run my python script in the background on a schedule?
10,924,388
1
5
0
0
4
1
1.2
0
Is there a high-level IMAP library for Python? With high-level I mean, that I do not want a library where I can issue basic IMAP commands (like Python's own imaplib). What I want, is library that cares about most of the IMAP details and gives me a more generic interface with objects for folders/mailboxes and messages. Additionally, it would be nice if it supports the disconnected mode of operation (offline mode) transparently.
0
python,imap
2012-06-10T12:07:00.000
0
10,968,541
To answer your question: What you're looking for doesn't exist in the wild AFAIK. Short of that, have you considered calling context.io from Python?
0
3,078
true
0
1
High-Level IMAP library for Python
12,879,530
1
5
0
-1
0
1
-0.039979
0
I will be running a programming competition for high school students in the near future, and was originally going to use PC^2 (Programming Contest Control System) for the automated judging of the solutions. This software is commonly used in the ACM's International Collegiate Programming Contest regionals as well as the world finals. This is an excellent system which I have used before, but one of its pitfalls is its language support (Java, C, and C++). I'm a little bit concerned, as not all high school students who may be attending will have exposure to any of these languages. However, many local high schools teach introductory programming courses in Python. Is there an equivalent system to PC^2 which has Python support?
0
python
2012-06-10T15:43:00.000
0
10,970,042
It's simpler than one may think. The following is for pc2 9.2.3-2565 Add language as follows (python here as an example): Display Name: Python Compile Cmd Line: touch OK Executable Filename: OK Program Execution Command Line: python {:mainfile} python3.3 or python3.4 will work too. pc2 could be easier, of course, but there does not seem to be much support left at CSUS. Reseting contest would be even greater feature; the current need to clone directories for test, practice, and actual contest is very awkward. Better management of the database (like the ability to remove things) would make it into a great tool. It is alright, but it could be great.
0
1,041
false
0
1
PC^2 equivalent compatible with Python
23,380,402
1
2
0
0
2
1
0
0
I'm experienced in PHP and recently started studying Python, and right now I'm on creating a small web project using django. And I have a conceptual question about approach to installing modules in Python and django. Example: based on expected needs for my project I've googled and downloaded django_openid module. And obviously I want to install it to my project. However, when I do it the prescribed way (python setup.py install) it installs it to python dir as a python module. Thus this module becomes not project specific, but system-wide. So, what is generally right approach to install project-specific modules in python? Based on my PHP experience it looks strange to install high level functional modules into the python itself. I'd rather expect it to be installed in the project library and included in the project on runtime. Or do I loose something important here? I've googled around, but as long as this is rather a conceptual approach question - keywords search doesnt work good in this case.
0
python,module
2012-06-12T08:27:00.000
0
10,992,976
Technically for any Python module to be "installed" you just have to add it to the sys.path variable, so that Python can find and import it. Same goes with django apps, which are Python modules. As long as Python can find and import the django application, you just have to add it to INSTALLED_APPS in settings (and maybe few more steps usually described in the application, e.g. adding urls etc).
0
223
false
1
1
python project-specific modules installation approach
10,993,067
1
1
0
2
1
0
0.379949
0
I am testing several different algorithms (for solving 16x16 sudokus) against each other, measuring their performance using the timeit module. However, it appears that only the first of the timeit.repeat() iterations is actually calculated, because the other iterations are gotten much faster. Testing a single algorithm with t.repeat(repeat=10, number=1) the following results are gotten: [+] Results for......: solve1 (function 1/1) [+] Fastest..........: 0.00003099 [+] Slowest..........: 32.38717794 [+] Average*.........: 0.00003335 (avg. calculated w/o min/max values) The first out of 10 results always takes an much larger time to complete, which seems to be explainable only by the fact that iterations 2 to 10 of the timeit.repeat() loop somehow use the cached results of the loop's previous iterations. When actually using timeit.repeat() in a for loop to compare several algorithms against each other, again it appears that the solution to the puzzle is calculated only once: [+] Results for......: solve1 (function 1/3) [+] Fastest..........: 0.00003099 [+] Slowest..........: 16.33443809 [+] Average*.........: 0.00003263 (avg. calculated w/o min/max values) [+] Results for......: solve2 (function 2/3) [+] Fastest..........: 0.00365305 [+] Slowest..........: 0.02915907 [+] Average*.........: 0.00647599 (avg. calculated w/o min/max values) [+] Results for......: solve3 (function 3/3) [+] Fastest..........: 0.00659299 [+] Slowest..........: 0.02440906 [+] Average*.........: 0.00717765 (avg. calculated w/o min/max values) The really weird thing is that relative speed (in relation to each other) of the algorithms is consistent throughout measurements, which would indicate that all algorithms are calculating their own results. Is this extreme increase in performance due to the fact that a large part of the intermediate results (gotten when computing the first solution) are still in some sort of cache, reserved by the python proces? Any help/insights would be greatly appreciated.
0
python,caching,timeit
2012-06-12T10:04:00.000
0
10,994,405
I think the memory allocation is the problem. the python interpreter itself holds a memory pool, which starts with no (or little?) memory pooling. after the first run of your program, much memory is allocated (from the system) and free (to the pool), and then the following runs get memory from the pool, which is much faster than asking memory from system. but this makes sense only if your algorithm will consume much memory.
0
1,635
false
0
1
Python timeit: results cached instead of calculated?
10,994,548
1
1
0
6
5
1
1.2
0
I am trying to do python documentation generation with Sphinx. The problem is that sphinx-build ends up executing the module/evaluating anything in global scope. Is there a reason it does this? And does anyone know of a flag that can be set to disable this? It seems like Sphinx is trying to do code-coverage or something equivalent, which is definitely not what I want it doing. Normally this wouldn't be an issue, but a particular set of modules are very specific to an environment.
0
python,python-sphinx
2012-06-13T00:07:00.000
0
11,006,553
Sphinx evaluates everything in the global scope because the autodoc plugin imports modules, and importing a module evaluates everything in the global scope. To stop this, either: Disable the autodoc plugin (search for autodoc in the sphinx config file), or Guard the code you don't want executed with something like if __name__ == "__main__": do_stuff()
0
1,993
true
0
1
Prevent Sphinx from executing the module
11,006,581
1
2
0
1
1
1
0.099668
0
I am currently parsing large text files with Python 2.7, some of which were originally encoded in Unicode or UTF-8. For modules containing functions which directly interact with strings in UTF-8, I included # -*- coding: utf-8 -*- at the top of the file, but for functions which work with only ascii, I did not bother. Eventually, these modules lead to larger modules, and all the parsed strings gets mixed together. Is it good practice to include # -*- coding: utf-8 -*- at top of every file? Is there a benefit to this?
0
python,parsing,unicode,utf-8,ascii
2012-06-14T08:52:00.000
0
11,029,721
Every ASCII file is also a valid UTF-8. Don't worry about treating your ASCII files as UTF-8 files, no conversion necessary, no increase in size.
0
2,205
false
0
1
Mixed usage of UTF-8 and ASCII encodings?
11,029,801
1
1
0
3
2
1
1.2
0
I cannot compile python in pydev in eclipse. I get the following error: "unable to make launch because launch configuration is not valid Reason: Interpreter: Python32 not found" I am actually runnning Python26 and have configured Python26 as the interpreter in "Windows->Preferences" I have deleted and replaced my copy of eclipse and this persists. Any help would be appreciated. I think that at one time I had Python32 running and then switched to Python26.
0
python,eclipse
2012-06-14T13:59:00.000
1
11,034,733
You probably still have that selected in your project or launch configuration... You can try to delete your existing launch configurations (run > run configurations) so that they get recreated on a new run and if that's not it, take a look at your project properties > pydev - interpreter/grammar and see if an old interpreter was selected.
0
820
true
0
1
Eclipse and pyddev: Error can't find Python32
11,192,462
1
1
0
1
0
0
0.197375
0
I'm a liberal arts major and have a few ideas for some web apps. I've saved up enough money to hire someone to do the coding for me, but I want to pick up at least basic coding skills on my own. I'd rather not be the clueless founder. I've started off with Python. So far, so good. Despite my liberal arts background, I've always been pretty mathematically inclined, even taking some advanced calculus classes in college. My question is: if my goal is to make web apps and not actually land a job, is it really necessary to learn more than one programming language? I'm starting off with Python and I've found it flexible and powerful enough to meet most of my needs. Do I need to expand my oeuvre to PHP, Ruby, Java, etc.?
0
python
2012-06-17T11:02:00.000
0
11,070,805
I'd stick with one server side language for now - and Python (or any of the other languages you listed) is a perfectly good choice for that. Basic notions of what Javascript would be important I think, and how and what Ajax type technology can do. However, stretching the definition of "language" a little, I think you develop a reasonable understanding of html and css as these are integral to web-development.
0
96
false
1
1
Do I really need to know more than one language if i want to make webapps?
11,070,833
2
2
0
1
1
0
0.099668
0
I am accessing the twitter streaming API. I generate a map using Basemap in python. I want only certain parts of the map to change with time (for eg. every second). Is it hard to do? Do I need to leave Basemap and look for something else? Please help!
0
python,django,dynamic,web,matplotlib
2012-06-18T02:42:00.000
0
11,076,404
You can send an ajax request and update the html contents dynamically.
0
215
false
0
1
Dynamically updating images on website
11,076,420
2
2
0
1
1
0
0.099668
0
I am accessing the twitter streaming API. I generate a map using Basemap in python. I want only certain parts of the map to change with time (for eg. every second). Is it hard to do? Do I need to leave Basemap and look for something else? Please help!
0
python,django,dynamic,web,matplotlib
2012-06-18T02:42:00.000
0
11,076,404
A possible approach: divide the map into tiles, and treat each one separately; use Basemap to generate just the map-tile that contains new data, then update just that tile on your webpage using Ajax. Of course, depending on the nature of changes to the data on your map, this approach may or may not work for you -- gerrymandering is not really possible. You would need to write logic to understand which tile the new data belongs to, then use basemap to create a new image for that time, then intelligently update the tiled image. You will also have to play with margins and padding (both in matplotlib and in CSS) to cleanly piece the tiles together. ... When the approach gets this complicated, one should re-evaluate whether better tools are available. Basemap doesn't sound like a good fit for what you need to do.
0
215
false
0
1
Dynamically updating images on website
11,093,825
1
1
0
0
0
1
0
0
How to install python module openFlashChart? I am really having trouble installing it. If you have installed it before kindly post how. The error was module openFlashChart not found. I actually cant find the module to install.
0
python,open-flash-chart,openflashchart2
2012-06-19T06:03:00.000
0
11,095,247
Correct me if I'm wrong but flash chart is a flash not python. There is no python module dedicated to flash chart. In fact flash chart need some data from server which can be implemented in python.
0
147
false
0
1
installing python module openFlashChart
11,095,835
2
2
0
0
2
0
0
0
I'm currently building Python regression tests using Jenkins. For some reason, each individual test in the test suite is taking approx. 15 minutes to run (and there are about 70/80 tests total) in Jenkins, but when I run the tests from the command line on the same windows box, each individual tests takes only about 30seconds to 1minute to run. I even put print statements in some of the files and none of them show up on the jenkins command line output. Has anyone else faced this problem or have any suggestions? Thanks Also, I'm not doing a sync every time I build, only syncing once!
0
python,windows,selenium,build,jenkins
2012-06-19T16:28:00.000
1
11,105,304
Check load on the machine and ensure you set Jenkins with enough memory to run those tests. It is not clear if you are working with Jenkins-slaves or directly on the master - This may also have an affect on performance.
0
2,535
false
0
1
Jenkins takes too long to execute
11,126,510
2
2
0
1
2
0
1.2
0
I'm currently building Python regression tests using Jenkins. For some reason, each individual test in the test suite is taking approx. 15 minutes to run (and there are about 70/80 tests total) in Jenkins, but when I run the tests from the command line on the same windows box, each individual tests takes only about 30seconds to 1minute to run. I even put print statements in some of the files and none of them show up on the jenkins command line output. Has anyone else faced this problem or have any suggestions? Thanks Also, I'm not doing a sync every time I build, only syncing once!
0
python,windows,selenium,build,jenkins
2012-06-19T16:28:00.000
1
11,105,304
This may have to do with running Jenkins in the background (and/or as a service). Try running it in the foreground with java -jar jenkins.war an see if it helps.
0
2,535
true
0
1
Jenkins takes too long to execute
11,109,668
1
6
0
1
25
1
0.033321
0
I have been asked to write a script that pulls the latest code from Git, makes a build, and performs some automated unit tests. I found that there are two built-in Python modules for interacting with Git that are readily available: GitPython and libgit2. What approach/module should I use?
0
python,git
2012-06-20T06:23:00.000
0
11,113,896
If GitPython package doesn't work for you there are also the PyGit and Dulwich packages. These can be easily installed through pip. But, I have personally just used the subprocess calls. Works perfect for what I needed, which was just basic git calls. For something more advanced, I'd recommend a git package.
0
45,496
false
0
1
Use Git commands within Python code
58,983,005
1
6
0
0
21
0
0
0
I'm currently using FileStorage class for storing matrices XML/YAML using OpenCV C++ API. However, I have to write a Python Script that reads those XML/YAML files. I'm looking for existing OpenCV Python API that can read the XML/YAML files generated by OpenCV C++ API
0
c++,python,image-processing,opencv
2012-06-21T15:18:00.000
0
11,141,336
pip install opencv-contrib-python for video support to install specific version use pip install opencv-contrib-python
1
16,840
false
0
1
FileStorage for OpenCV Python API
60,879,363
1
2
0
0
1
1
1.2
0
other than not encrypting, i have no choice but to have the RSA private key on the same system as the data encrypted asymetrically. (my system has no access to remote servers, etc) so i figured using seahorse (ubuntu) or keychain access (apple) might be useful? is it possible to access the private key stored in one of these from python? are there other approaches to this besides not storing the private key locally? i need a reversible crypt so hashing is not an option.
0
python,django,encryption,keystore,keychain
2012-06-21T15:56:00.000
0
11,142,044
On Mac OS X, the keychain can be accessed from the shell using the security program. You can search for a specific private key using security find-identity -s <search term>, and export it to a file using security export (more information on those commands can be obtained from security -h <command>). I have not seen python bindings yet, but it should be easy to wrap the functionality you need in a subprocess.call call.
0
1,455
true
0
1
can python access an RSA private key stored locally in a keystore like seahorse / Apple Keychain
11,146,119
2
4
0
2
0
0
1.2
0
A python program opens a new process of the C++ program and is reading the processes stdout. No problem so far. But is it possible to have multiple streams like this for communication? I can get two if I misuse stderr too, but not more. Easy way to hack this would be using temporary files. Is there something more elegant that does not need a detour to the filesystem? PS: *nix specific solutions are welcome too
0
python,process,communication,iostream
2012-06-22T21:10:00.000
0
11,164,176
On unix systems; the usual way to open a subprocess is with fork(), which will leave any open file descriptors (small integers representing open files or sockets) available in both the child, and the parent, and then exec(), which also allows the new executable to use the file descriptors that were open in the old process. This functionality is preserved in the subprocess.Popen() call (adjustable with the close_fds argument). Thus, what you probably want to do is use os.pipe() to create pairs of sockets to communicate on, then use Popen() to launch the other process, with arguments for each of fd's returned by the previous call to pipe() to tell it which fd's it should use.
0
270
true
0
1
C++ to python communication. Multiple io streams?
11,164,681
2
4
0
0
0
0
0
0
A python program opens a new process of the C++ program and is reading the processes stdout. No problem so far. But is it possible to have multiple streams like this for communication? I can get two if I misuse stderr too, but not more. Easy way to hack this would be using temporary files. Is there something more elegant that does not need a detour to the filesystem? PS: *nix specific solutions are welcome too
0
python,process,communication,iostream
2012-06-22T21:10:00.000
0
11,164,176
assuming windows machine. you could try using the clipboard for exchanging information between python processes and C++. assign some unique process id followed by your information and write it to clipboard on python side.....now just parse the string on C++ side. its akin to using temporary files but all done in memory..... but the drawback being you cannot use clipboard for any other application. hope it helps
0
270
false
0
1
C++ to python communication. Multiple io streams?
11,165,324
2
2
0
1
0
0
1.2
0
I am using heliohost's free service to test my django apps. But Heliohost does not provide me shell access. Is there anyway to install python libraries on the host machine?
0
python,django,web-hosting,cpanel
2012-06-23T10:23:00.000
1
11,168,747
You could try to put them in your PYTHONPATH. Usually, your current working directory is in your PYTHONPATH. If that changes, you might need to add a path to it (maybe in each file, you should check, or one common file which is always included), and put the libraries there. You can do this with import sys;sys.path.append(the_path) I'm not sure all of the libraries will work, but those which are pure-python, you should be able to copy/paste the source in a directory, and they will work I think.
0
1,172
true
1
1
python libraries in cpanel
11,169,154
2
2
0
0
0
0
0
0
I am using heliohost's free service to test my django apps. But Heliohost does not provide me shell access. Is there anyway to install python libraries on the host machine?
0
python,django,web-hosting,cpanel
2012-06-23T10:23:00.000
1
11,168,747
You should inform the support of heliohost.this server has very good support that help you or install any package you want
0
1,172
false
1
1
python libraries in cpanel
45,138,203
1
2
1
0
1
0
0
1
I'd like to invoke PySocketModule_ImportModuleAndAPI function defined in socketmodule.h in my Python C-extension.
0
python-c-extension,python-extensions
2012-06-23T19:07:00.000
0
11,172,215
I had a similar problem and resolved it by: Adding the Modules\ directory (from your Python source) to the C/C++ Additional Include Directories. #include "socketmodule.h" Don't know if this is the best solution, but it worked for me!
0
142
false
0
1
Is it possible to include socketmodule.h in Python C extensions?
20,085,116
1
10
0
0
2
1
0
0
What is the most efficient way to sort a list, [0,0,1,0,1,1,0] whose elements are only 0 & 1, without using any builtin sort() or sorted() or count() function. O(n) or less than that
0
python
2012-06-24T07:14:00.000
0
11,175,645
You have only two values, so you know in advance the precise structure of the output: it will be divided into two regions of varying lengths.
0
1,534
false
0
1
Sort a list efficiently which contains only 0 and 1 without using any builtin python sort function?
11,175,666
1
1
0
2
2
0
0.379949
0
I know this question has been asked many times and it's also covered in official memcached FAQ. But my case is - I want to use it just for admin panel purposes. I want to see keys with values in my admin page so it doesn't matter if it's slow and against the best practices. Please advise, if it's possible.
0
python,caching,memcached
2012-06-24T09:15:00.000
0
11,176,273
There's no way to do it that's guaranteed to work. The only way I found is the way you'll find on google, but there's a restriction: Only 1 MB will be returned - it may not be all keys. And it will probably be quite slow.. If you really, really has to have all those keys you'd probably have to hack the source code. I would say: no, you can't. Why do you need all those key? I would consider redesigning your application to not make your admin panel dependent of the internals of a caching server
0
839
false
1
1
List all memcached keys/values
11,176,318
2
2
0
5
6
1
0.462117
0
I'm trying to understand whether and under what circs one should use Python classes and/or Java ones. If making a specialist dictionary/Map kind of class, should one subclass from Python's dict, or from Java's HashMap or TreeMap, etc.? It is tempting to use the Python ones just because they are simpler and sexier. But one reason that Jython runs relatively slowly (so it appears to me to do) seems to have something to do with the dynamic typing. I'd better say I'm not that clear about all this, and haven't spent nocturnal hours poring over the Python/Jython interpreter code, to my shame. Anyway it just occurs to me that the Java classes might possibly run faster because the code might have to do less work. OTOH maybe it has to do more. Or maybe there's nothing in it. Anyone know?
0
java,python,jython
2012-06-24T14:24:00.000
0
11,178,243
The point of using Jython is that you can write Python code and have it run on the JVM. Don't ruin that by making your Python into Java. If -- if -- it turns out that your data structure is too slow, you can drop-in replace it with a Java version. But that's for the optimisation stage of programming, which comes later. I guess I should try to answer your question. I would guess that using native Java structures will be faster (because the JVM can infer more about them than the Python interpreter can), but that might be counterbalanced by the extra processing needed to interface with Jython. Only tests will tell!
0
418
false
1
1
Jython - is it faster to use Python data structures or Java ones?
11,178,285
2
2
0
4
6
1
1.2
0
I'm trying to understand whether and under what circs one should use Python classes and/or Java ones. If making a specialist dictionary/Map kind of class, should one subclass from Python's dict, or from Java's HashMap or TreeMap, etc.? It is tempting to use the Python ones just because they are simpler and sexier. But one reason that Jython runs relatively slowly (so it appears to me to do) seems to have something to do with the dynamic typing. I'd better say I'm not that clear about all this, and haven't spent nocturnal hours poring over the Python/Jython interpreter code, to my shame. Anyway it just occurs to me that the Java classes might possibly run faster because the code might have to do less work. OTOH maybe it has to do more. Or maybe there's nothing in it. Anyone know?
0
java,python,jython
2012-06-24T14:24:00.000
0
11,178,243
Generally, the decision shouldn't be one of speed - the Python classes will be implemented in terms of Java classes anyway, even if they don't inherit from them. So, the speed should be roughly comparable, and at most you would save a couple of method calls per operation. The bigger question is what you plan on doing with your class. If you're using it with Python APIs, you'll want to use the Python types, or something that behaves like them so that you don't have to do the work of implementing the entire Mapping protocol (only the bits your class changes). If you're using Java APIs, you will certainly need to meet the static type checks - which means you'll need to inherit from Java's classes. If this isn't easy to answer in your situation, start with the Python ones, since you (correctly ;-) find them "simpler and sexier". If your class doesn't pass outside the boundaries of your project, then this should be trivial to change later if the speed really becomes an issue - and at that point, you might also be thinking about questions like "could it help to implement it entirely at the Java level?" which you've hopefully recognised would be premature optimisation to think about now.
0
418
true
1
1
Jython - is it faster to use Python data structures or Java ones?
11,179,152
2
2
0
0
0
0
0
1
I need a url for using that for a template. Now there are two ways of storing the url and use that again in python I guess... One is using session to store that URL and get it later whenever we need it... or Second is using cookies to store that URL and get it later.. So which method is more appropriate in terms of security ? Is there any other method in python which is more better for storing the url and use that later, which is more secure..? While using cookies somebody can easily change the information I guess, in sessions also somebody can hijack it and make the changes....
0
python,django,http
2012-06-25T11:43:00.000
0
11,188,725
In terms of security, you should store it in session. If it's in cookie, the client can modify your url to whatever he wants.
0
276
false
0
1
Storing URL into cookies or session?
11,188,777