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 | 4 | 0 | 0 | 0.379949 | 0 | My boss has given me a list of around 3500 companies and wants the generic contact email for each of them by tomorrow. I know this sounds retarded, and it is, but our client is demanding it. The approach I'd like to take is this:
Carry out a google search for company name
Identify company website and redirect to it
Step through website links to find a contact us / about us page
Locate and return the first email address on the page
I've done a bit of python here and there, but nothing web based or with regex... though I get the basic ideas I don't know if I would be able to execute this in the next 12 hours.
If anyone has any help on how I could script this with python or ruby I would be very appreciative...... | 0 | python,ruby,regex,email | 2012-03-26T03:02:00.000 | 0 | 9,866,104 | I would look to a more non-technical solution. You could split out the 3500 names and post them to Amazon Mechanical Turk as a HIT, paying 1 cent for each. Then instead writing code to scrape Google, you write code to create the hits and let real people do the "scraping" of the company websites.
Don't know if that will work for you but that's probably what I'd do.
Hope that helps!
Brandon | 0 | 1,967 | false | 1 | 1 | Extract company contact details from google | 9,866,851 |
2 | 4 | 0 | 2 | 12 | 1 | 0.099668 | 0 | In Eclipse, how can I change default font for Python code in the editor (PyDev plugin)?
I navigate to menu Window → Preference → General → Appearance → Colors & Fonts, but I don't find which item would affect the Python code font. | 0 | python,eclipse,pydev | 2012-03-26T08:16:00.000 | 0 | 9,868,711 | On a Mac, I can get to the PyDev settings via:
Eclipse → Preferences → PyDev (in tree) → Editor (subtree)
In my case, I wanted to change hash tag comments from nearly invisible grey to a better color. It worked like a charm. | 0 | 16,217 | false | 0 | 1 | How do I change the default font for Python code in Eclipse? | 13,807,754 |
2 | 4 | 0 | 2 | 12 | 1 | 0.099668 | 0 | In Eclipse, how can I change default font for Python code in the editor (PyDev plugin)?
I navigate to menu Window → Preference → General → Appearance → Colors & Fonts, but I don't find which item would affect the Python code font. | 0 | python,eclipse,pydev | 2012-03-26T08:16:00.000 | 0 | 9,868,711 | Following the guidance of gecco, I found out the item in General → Appearance → Colors & Fonts which affects Python code fonts. It's Text Font in the Basic folder. | 0 | 16,217 | false | 0 | 1 | How do I change the default font for Python code in Eclipse? | 9,883,196 |
1 | 1 | 0 | 0 | 0 | 0 | 1.2 | 0 | I'm taking over a Satchmo site and need it to charge a different shipping rate for international versus local postage.
Any idea what I need to do to enable this? | 0 | python,django,shipping,satchmo | 2012-03-27T09:13:00.000 | 0 | 9,886,494 | it seems like the tieredweight shipping module is what I need here. | 0 | 84 | true | 0 | 1 | Different national and international shipping rate in Satchmo? | 14,647,712 |
1 | 1 | 0 | 1 | 1 | 0 | 1.2 | 0 | For some reason my 64 bit EPD can't import wx.
I also tried to install the wxPython2.8-osx-unicode-py2.7 version from the wx site.
It installed successfully, but is no where to be found on my harddrive.
I checked the sitepackes for 2.7 and the EPD 7.2.2. where all the modules usually should be installed.
I am confused.
This raises a similar question.
How can I install modules that are not part of EPD ?
I also didn't have luck to install other modules.
And every time I try to import older modules it doesn't work as well.
Often I get error message that architectures in universal rapper is wrong.
For example pygame doesn’t have a 64 bit version that works with 2.7, so I installed the 32 bit version.
If I try to do the trick arch -i386 /Path to python , I get "Bad CPU type in executable".
I am running a 64bit version of Python on a 64 bit Mac OS.
I wonder if the Enthougt 7.2 is equivalent with the 2.7 Python.
And if not, what I assume, what the differences are.
Any hints who can solve this, would be awesome.
Thanks for your patients. | 0 | python,64-bit,pygame,wxwidgets,enthought | 2012-03-27T19:53:00.000 | 1 | 9,896,687 | I had the same problem. The only way around it that has worked for me is to uninstall your EPD version ($ sudo remove-EPD-7.2-1, or whichever version you have) and reinstall the 32 bit version. Wx comes as part of the EPD package, so once you have downloaded the 32 bit version there is no need to download and install wx. | 0 | 682 | true | 0 | 1 | enthought python distribution wx | 11,151,178 |
1 | 1 | 0 | 2 | 1 | 1 | 0.379949 | 0 | This isn't as much of a specific problem as something I am looking for more of a "Pythonic" philosophical answer to. Namely, what's the best way to keep track of unique items and ensure duplicates don't arise?
For example, I am writing a script to scrape a website for links to songs on SoundCloud so I can automatically download them. If I want to automate this program with, say, cron, what's the most efficient way to ensure that I am downloading only content I don't have already?
Or if I downloaded images, how could I make sure that there aren't any duplicates, or have some sort of process that searches for and removes duplicates efficiently?
Kind of open ended, so contribute as little or as much as you please.
Thanks. | 0 | python,beautifulsoup,mechanize | 2012-03-27T23:48:00.000 | 0 | 9,899,313 | Use a dict or set. Consider computing a checksum of each item. This brings you toward what's known as Content Addressable Storage, which is where the checksum actually is stored as if it were the item's "name", and a separate index is stored which maps things like filenames or song names to the checksums or data blocks. The problem with the CAS approach in your particular case is that it may not be possible for you to get a checksum computed on the remote side for new content--that's how programs like rsync avoid copying duplicate data. | 0 | 214 | false | 0 | 1 | What is the most efficient way to keep track of unique downloaded files in a Python program? | 9,899,341 |
1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | I'm obtaining a PID, using python, of a CGI script, however, the PID is not valid i.e. can't Taskkill it from CL. I get:
"Process: no process found with pid xxxx" where xxxx is the pid
I thought maybe I have to kill a parent python shell instance, but os.ppid doesn't work in windows.
So then I installed psutil python module and can now get parent PID, but it just shows the parent as the actual WebServer (Abyss), which I don't think I want to kill, since it is the http process that I notice runs constantly and not just a CGI interpreter instance.
Using psutil I CAN get the process status of the actual script, using the pid returned by os.getpid(), and see that it is running. So the pid works for purposes of process information retrieval using psutil. But this gets me no further to obtaining the actual PID I need to kill the script, using EITHER Taskkill on the CL or via kill() from psutil!
What exactly is a cgi shell script from a process perspective, and if it is not a process, why is os.getpid() returning a pid? | 0 | python,windows,process,kill | 2012-03-28T16:47:00.000 | 1 | 9,912,121 | Why are you assured that your CGI script are still working when you try to kill it? Web server starts one instance of CGI script for one request and when script finishes it... just finishes. | 0 | 222 | false | 0 | 1 | Determing PID of CGI Script on Windows | 9,912,713 |
2 | 3 | 0 | 1 | 2 | 0 | 0.066568 | 0 | I want some help to generate a report in PDF/Doc(MS Word) format . I’m not able to find any module to generated report in doc, except “docx” which I’m not able to comprehend. Actually I’m actual task is to generate the report in Doc only, but as I’m not able to find a module to work on it, I opt for PDF. I’m using “Report Lab” module, but I’m finding some limitation in that. It write anything based on co-ordinate system. The problem I’m facing with that the report is usually a string, whose length is not limited, so sometime it goes beyond the canvas( Pdf Page). Also there is not functionality I guess to do format font with Bold, Italics and Underline.
If you know any module to generate report in PDF or Doc, please let me know. My requirement is:
Able to add an image at an header.
Change fonts and other properties, like Bold, Italics, and Underline
Able to draw basic shape like line
Write string, as a statement, as we are able to do with able to write into txt file using python(not on co-ordinate system basis) | 0 | python,ms-word,pdf-generation,report,reportlab | 2012-03-29T05:22:00.000 | 0 | 9,919,509 | I should point out you can do all the stuff you want in ReportLab by using the supporting PLATYPUS module. It lets you easily build documents out of objects in code. Alternatively, there is RML, a ReportLab way of building documents from an HTML-like markup language. | 0 | 1,604 | false | 0 | 1 | Need help to generate report in PDF or Doc using python | 9,930,989 |
2 | 3 | 0 | 1 | 2 | 0 | 0.066568 | 0 | I want some help to generate a report in PDF/Doc(MS Word) format . I’m not able to find any module to generated report in doc, except “docx” which I’m not able to comprehend. Actually I’m actual task is to generate the report in Doc only, but as I’m not able to find a module to work on it, I opt for PDF. I’m using “Report Lab” module, but I’m finding some limitation in that. It write anything based on co-ordinate system. The problem I’m facing with that the report is usually a string, whose length is not limited, so sometime it goes beyond the canvas( Pdf Page). Also there is not functionality I guess to do format font with Bold, Italics and Underline.
If you know any module to generate report in PDF or Doc, please let me know. My requirement is:
Able to add an image at an header.
Change fonts and other properties, like Bold, Italics, and Underline
Able to draw basic shape like line
Write string, as a statement, as we are able to do with able to write into txt file using python(not on co-ordinate system basis) | 0 | python,ms-word,pdf-generation,report,reportlab | 2012-03-29T05:22:00.000 | 0 | 9,919,509 | You could also try and generate LaTeX Code, which you then compile to PDF. | 0 | 1,604 | false | 0 | 1 | Need help to generate report in PDF or Doc using python | 9,931,947 |
1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | I'm new for python. How can I get gevent-py2.7-win64.egg, my system is win32, and I need a 64bit module of gevent | 0 | python,gevent | 2012-03-29T10:03:00.000 | 1 | 9,923,175 | first test cmd easy_install gevent
if failed, just go google python setuptools and then installed it and easy_install gevent
just let the setuptools to help you choose the suitable module | 0 | 377 | false | 0 | 1 | How can I get gevent-py2.7-win64.egg | 9,923,444 |
1 | 1 | 0 | 2 | 1 | 0 | 1.2 | 0 | I'm having a problem with eclipse+pydev. It suddenly refuses to parse a .py file as a python script, which means no syntax highlighting, code completion etc. It worked up until now, but I couldn't find a way to convince it to re parse it. re-opening the file, re-starting the IDE does not help. I suspect deleting some kind of meta-data file would do the trick.
Has anyone here encountered this and has a quick solution? I would greatly appreciate that! | 0 | python,eclipse,pydev | 2012-03-29T13:14:00.000 | 1 | 9,926,088 | Right click on the python file you care about and see what the default editor is. You can manually switch any file type here. If it's plain text, just switch it back to PyDev.
To ensure that the setting is global, go to Window > Preferences > General > Editors > File associations and look for .py, .pyw, and .pyx. They should all be set to "Python Editor (default)". If not, just select it and select default. If it's not there at all, you can select the "add" button and add it from there. | 0 | 439 | true | 0 | 1 | eclipse pydev refuses to parse a .py file | 9,926,632 |
3 | 4 | 0 | 0 | 3 | 0 | 0 | 0 | I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is.
I could work for hours trying to determine which Python GUI toolkit is "best", then learning how to do what I need, but it seems like this would have been done before.
Is there a relatively cook-book method to GUIify my program? Direction to either some sort of lesson/tutorial or an existing, documented, concise program would be excellent. | 0 | python,user-interface,wxpython,pyqt,tkinter | 2012-03-29T14:48:00.000 | 0 | 9,927,821 | Basically you just need to figure out what widgets will hold the data you want the best. I suspect you could use a couple combo boxes to hold different sets of extensions. Or you could just use the path name strings to figure that out. Hit a button and run the conversion process, probably in another thread so the GUI remains responsive.
I'm biased for wxPython. However, you're better off taking a look at their demos and documentation and seeing which GUI toolkit fits your brain the easiest. | 0 | 4,233 | false | 0 | 1 | Cookbook GUI interface for a command-line script | 9,928,114 |
3 | 4 | 0 | 1 | 3 | 0 | 0.049958 | 0 | I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is.
I could work for hours trying to determine which Python GUI toolkit is "best", then learning how to do what I need, but it seems like this would have been done before.
Is there a relatively cook-book method to GUIify my program? Direction to either some sort of lesson/tutorial or an existing, documented, concise program would be excellent. | 0 | python,user-interface,wxpython,pyqt,tkinter | 2012-03-29T14:48:00.000 | 0 | 9,927,821 | There are a few answers advocating wxpython. However, any toolkit will work for this project. Tkinter has the added benefit tha you and your collegues already have it installed and it is very easy to use.
That being said, the other toolkits are more-or-less equally easy to use but you might have to jump through a hoop or two to get them installed. If installation is not an issue it won't matter which one you pick.
Unfortunately, telling you how to "GUIfy" your program is hard since we know nothing about your app. Probably all it will involve is putting up a few labels and input widgets, then creating a button that collects all the data and then runs your program with the subprocess module. | 0 | 4,233 | false | 0 | 1 | Cookbook GUI interface for a command-line script | 9,934,956 |
3 | 4 | 0 | 0 | 3 | 0 | 0 | 0 | I have a command-line Python script that works well to convert one sort of file into another given a few parameters and would now like to deploy this to some of my colleagues who may not know what a command line is.
I could work for hours trying to determine which Python GUI toolkit is "best", then learning how to do what I need, but it seems like this would have been done before.
Is there a relatively cook-book method to GUIify my program? Direction to either some sort of lesson/tutorial or an existing, documented, concise program would be excellent. | 0 | python,user-interface,wxpython,pyqt,tkinter | 2012-03-29T14:48:00.000 | 0 | 9,927,821 | This depends mostly on your need. If your need is simple, you can just go with tkinter that is bundled with python itself. If you use this, you will not be relying on third party library to implement your GUI. Since you are wanting to make this available for your collegues, this might be easier to compile with py2exe or other similar stuffs to exe which might be tricky if you use third party library for GUI. However, if you want to add more functionality to your GUI, wxpython/pyqt/pyGTK are the GUI toolkit to look for. Personally, I favor wxpython due to its cross-platform nature but pyqt and pyGTK are also equally good as far as I have heard. | 0 | 4,233 | false | 0 | 1 | Cookbook GUI interface for a command-line script | 9,928,262 |
1 | 1 | 0 | 0 | 2 | 0 | 0 | 0 | I am registering a signal for remote debugging:
signal.signal(signal.SIGUSR1, lambda x,y: remote_debug(x, y, emp_id))
While normally very fast, log statements show this command (register) sometimes takes 5 to 10 seconds to execute. What is causing this? How can I fix it? | 0 | python,signals | 2012-03-30T06:50:00.000 | 0 | 9,938,238 | The Python callback code is not actually called right away in Python. The C code in Python just sets a flag when it gets a signal. It only runs the handler when it returns to the interpreter. If your code path is currently working in an extension module in compiled code the handler won't get run until it finishes.
The only way to fix it is to ensure that the execution path doesn't spend a lot of time in a C function. What function are you running at that time? Another culprit is the standard time.sleep() method. Use signal.pause() instead. | 0 | 69 | false | 0 | 1 | What can make signal.signal block for a long time? | 9,939,503 |
2 | 3 | 0 | 0 | 0 | 0 | 0 | 1 | I'm making a server which is controlled by php scripts, i have clients (androidphones) who calls these script to control the server. I'm saving the ip's the php receives to the DB.
now i'm looking for a way to check if these ip's are still reachable..
this is what i tried so far:
Cron job -> i'm developing with usbwebserver so i cant use php from cmd
make a ping request to the ip from the php script: if available it will return rather "fast" but if it fails i get the maximum excution error. this way of working get me the results i want but without the possibilty of threading this, this solution isnt going to perform in time as i wanted. is there a way this approach could work?
something i'm considering: -
make a request to de device through http, and do something with the result i get back, is this even possible (making a request from server to client)?
making a python script that gets the ip from db and makes the ping calls and stores the results back into the db.
making timestamps when a device connects and check timestamps from other devices, if max time was exceeded then update DB
any suggestions? | 0 | php,python,mysql,request,ip | 2012-03-30T11:54:00.000 | 0 | 9,942,423 | This will not work, as you will always must have your client responding. I suggest using the client (eg. in html using javascript) to make a connection (ping) every minute from your script on the client to your server, and in your cronjobs letting a script run every x minutes to update the clients that didn't within x. | 0 | 692 | false | 0 | 1 | PHP make a request check if client is available via ip | 9,942,581 |
2 | 3 | 0 | 0 | 0 | 0 | 0 | 1 | I'm making a server which is controlled by php scripts, i have clients (androidphones) who calls these script to control the server. I'm saving the ip's the php receives to the DB.
now i'm looking for a way to check if these ip's are still reachable..
this is what i tried so far:
Cron job -> i'm developing with usbwebserver so i cant use php from cmd
make a ping request to the ip from the php script: if available it will return rather "fast" but if it fails i get the maximum excution error. this way of working get me the results i want but without the possibilty of threading this, this solution isnt going to perform in time as i wanted. is there a way this approach could work?
something i'm considering: -
make a request to de device through http, and do something with the result i get back, is this even possible (making a request from server to client)?
making a python script that gets the ip from db and makes the ping calls and stores the results back into the db.
making timestamps when a device connects and check timestamps from other devices, if max time was exceeded then update DB
any suggestions? | 0 | php,python,mysql,request,ip | 2012-03-30T11:54:00.000 | 0 | 9,942,423 | There is absolutely no point in such checking.
You will always have these IPs UP.
Just because an android client seldom have a real IP but using Net via some router/proxy.
Web is one-way road.
To implement a heart-beat feature you have to make your android clients to ping server. | 0 | 692 | false | 0 | 1 | PHP make a request check if client is available via ip | 9,942,749 |
2 | 7 | 0 | 1 | 4 | 0 | 0.028564 | 1 | I am a newborn programmer still programming from the book on my Alt+Tab. One of the first programs I want to create is to help my mom in her work. I need to know if I can use Python to create it.
It needs to:
Go on-line and log-in with account / pass.
Do a search with specific criteria (use the site's search engine)
View all the results and pick only the newest ones.
Sort them out.
Notify me so that the newest adds are noticed the moment they are posted on the website.
From what I see the site says : .cgi in the end.
I know python can connect, download the text from a page and sort the wanted info, but can it log in, use the search engine and pick the options I need?
I don't want to skip my learning process, but I am so serious about this project I am ready to put Python on hold and start learning some language that can do it!
I will very much appreciate your guidance!
Thank you for your time!
AJ | 0 | python,automation,notifications | 2012-03-30T14:45:00.000 | 0 | 9,945,206 | If I understand well, the idea of your program is to do an automated browsing session.
So yes, it's possible. It's not important in what the website is programmed (cgi, php etc). All you need is to send data through post/get (like a real browser) and process the return (regexp and so on).
Good luck | 0 | 10,966 | false | 1 | 1 | Can web automation be done in Python? | 9,945,337 |
2 | 7 | 0 | 1 | 4 | 0 | 0.028564 | 1 | I am a newborn programmer still programming from the book on my Alt+Tab. One of the first programs I want to create is to help my mom in her work. I need to know if I can use Python to create it.
It needs to:
Go on-line and log-in with account / pass.
Do a search with specific criteria (use the site's search engine)
View all the results and pick only the newest ones.
Sort them out.
Notify me so that the newest adds are noticed the moment they are posted on the website.
From what I see the site says : .cgi in the end.
I know python can connect, download the text from a page and sort the wanted info, but can it log in, use the search engine and pick the options I need?
I don't want to skip my learning process, but I am so serious about this project I am ready to put Python on hold and start learning some language that can do it!
I will very much appreciate your guidance!
Thank you for your time!
AJ | 0 | python,automation,notifications | 2012-03-30T14:45:00.000 | 0 | 9,945,206 | I would point out that depending upon what site you are on, there may be a more efficient way (perhaps an exposed web service) than scraping data from the page and working with mechanize/selenium to do what you want. If you are on the web, browser driver tools are the hammers, and they will get the screws in the wood, but sometimes another tool will work better. | 0 | 10,966 | false | 1 | 1 | Can web automation be done in Python? | 9,945,530 |
1 | 1 | 0 | 1 | 0 | 0 | 1.2 | 1 | I'm writing a python program to get rsa public key. Is there a way to get it via paramiko or I just read it like plain text and with the assumption from id_rsa.pub? | 0 | python,ssh,paramiko | 2012-03-30T16:18:00.000 | 0 | 9,946,744 | If you don't know where the public key file is located, Paramiko can't help you either - it also needs you to specify where it is. You can of course try the usual places (starting by parsing ~/.ssh/config if available), but you don't need Paramiko for that. | 0 | 215 | true | 0 | 1 | Can we get public key using Paramiko? Or just read it like plain text? | 9,947,158 |
1 | 2 | 0 | 1 | 0 | 0 | 1.2 | 0 | I'm developing a system, and I have build a code generator that emits a bunch of classes based on a configuration file.
I would like to configure PyDev to invoke the generator for me whenever the configuration file (or the generator source) changes. I know that this is possible "in theory" because e.g., the ANTLR plugin for Eclipse does this in Java.
Is there any kind of support in PyDev for doing this? If not, is there some other Eclipse hackery that I can use to get this working? | 0 | eclipse,python-3.x,pydev,generated-code | 2012-03-31T01:49:00.000 | 1 | 9,952,327 | It should be possible to do what you want using an external builder inside Eclipse...
Right click project > properties > builders > new > program, then configure the program as python having as a parameter the module to run and receiving as arguments also the ${build_files} variable (if it's a python script, you have to put your Python.exe as the executable, your main file as an argument and then the ${build_files} variable). | 0 | 339 | true | 1 | 1 | How do I generate code under Eclipse+PyDev? | 9,998,578 |
1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | I am currently using gaeunit to perform automated test on my google app engine application. I am wondering whether it's possible to simulate the user login action using his/her google account using gaeunit?
Thank you very much. | 0 | python,google-app-engine,google-apps,google-signin,gaeunit | 2012-03-31T03:50:00.000 | 1 | 9,952,873 | Two situations:
Local Dev server: login is mocked via a simple web form. You can do a http POST to log in.
Production server: login goes through the Google auth infrastructure. No way to mock this. To make this work you'd need to code around it. | 0 | 401 | false | 1 | 1 | How to simulate Google login using gaeunit | 9,953,084 |
1 | 1 | 0 | 5 | 3 | 1 | 0.761594 | 0 | I've recently started using eclipse for my class over IDLE. So far I have no problems writing new code and creating new projects in eclipse.
However, when I open older code that was not originally written in my current project, eclipse seems to only open it as a text file.
For example, when I want to run a piece of code, I get a popup asking for an ANT build instead of running it using pydev. Also the code will not show up in the pydev package explorer.
How do I go about importing the source code into my project so eclipse will treat it as such. | 0 | python,eclipse,pydev | 2012-04-01T01:28:00.000 | 0 | 9,961,190 | File > Import > "General" Folder > "File System" Folder > "Browse" button | 0 | 5,598 | false | 0 | 1 | Python: Import Source Code into Eclipse | 9,961,465 |
1 | 2 | 0 | 1 | 0 | 1 | 0.099668 | 0 | I have a zmq directory in cwd . when i import zmq from a python file running under apache it gives me import error. but when i import zmq using console from current directory it imports.
How to make this import possible from anywhere in my server? | 0 | python,zeromq,pyzmq | 2012-04-02T10:18:00.000 | 0 | 9,974,611 | Are you sure that zmq is installed on computer?
If not then try installing it. In ubuntu it is quite easy
sudo apt-get install python-zmq | 0 | 2,387 | false | 0 | 1 | python import error when importing zmq | 9,975,162 |
2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | I have a program (not written by me) that I would like to use. It authenticates to an online service using a username and password that I would like to keep private. The authentication information may be passed to the program in two ways: either directly as command-line arguments or via a plaintext configuration file, neither of which seem particularly secure.
I would like to write a Python script to manage the launching of this program and keep my credentials away from the prying eyes of other users of the machine. I am running in a Linux environment. My concerns with the command-line approach are that the command line used to run the program is visible to other users via the /proc filesystem. Likewise, a plaintext configuration file could be vulnerable to reading by someone with the appropriate permissions, like a sysadmin.
Does anyone have any suggestions as to a good way to do this? If I had some way of obscuring the arguments used at the command line from the rest of the system, or a way to generate a configuration file that could be read just once (conceptually, if I could pipe the configuration data from the script to the program), I would avoid the situation where my credentials are sitting around potentially readable by someone else on the system. | 0 | python,security,passwords,pipe | 2012-04-03T01:38:00.000 | 1 | 9,986,059 | Tough problem. If you have access to source code of the program in question, you can change argv[0] after startup. On most flavors of *nix, this will work.
The config file approach may be better from a security perspective.
If the config file can be specified at run time, you could generate a temp file (see mkstemp), write password there, and invoke subprocess. You could even add a small delay (to give subprocess time to do its thing) and possibly even remove the config file.
Of course the best solution is to change the program in question to read password from stdin (but it sounds like you already knew that) | 0 | 1,344 | false | 0 | 1 | Securely passing credentials to a program via plaintext file or command line | 9,986,152 |
2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | I have a program (not written by me) that I would like to use. It authenticates to an online service using a username and password that I would like to keep private. The authentication information may be passed to the program in two ways: either directly as command-line arguments or via a plaintext configuration file, neither of which seem particularly secure.
I would like to write a Python script to manage the launching of this program and keep my credentials away from the prying eyes of other users of the machine. I am running in a Linux environment. My concerns with the command-line approach are that the command line used to run the program is visible to other users via the /proc filesystem. Likewise, a plaintext configuration file could be vulnerable to reading by someone with the appropriate permissions, like a sysadmin.
Does anyone have any suggestions as to a good way to do this? If I had some way of obscuring the arguments used at the command line from the rest of the system, or a way to generate a configuration file that could be read just once (conceptually, if I could pipe the configuration data from the script to the program), I would avoid the situation where my credentials are sitting around potentially readable by someone else on the system. | 0 | python,security,passwords,pipe | 2012-04-03T01:38:00.000 | 1 | 9,986,059 | About the only thing you can do in this situation is store the credentials in a text file and then deny all other users of the machine permissions to read or write it. Create a user just for this script, in fact. Encrypting doesn't do much because you still have to have the key in the script, or somewhere the script can read it, so it's the same basic attack. | 0 | 1,344 | false | 0 | 1 | Securely passing credentials to a program via plaintext file or command line | 9,986,183 |
1 | 2 | 0 | 2 | 1 | 1 | 1.2 | 0 | Assuming I have a instance of class A (name it AI)
that has an instance of class B (name it BI).
Can a reference to BI (somewhere else) tell me that it is part of AI?
I don't talk about inheritance/parent class.
I know I can do this by implementing a reference to A
in the constructor of B - but can mighty Python do it for me? | 0 | python | 2012-04-03T07:01:00.000 | 0 | 9,988,578 | can mighty Python do it for me?
No, you have to do it yourself (by having every instance of B keep a reference to the corresponding instance of A). | 0 | 429 | true | 0 | 1 | Get containing python class from element | 9,988,597 |
1 | 2 | 0 | 1 | 0 | 1 | 1.2 | 0 | I currently have a python script that runs every few minutes and picks up "rules", in my case python classes, within files in a directory tree. for each class it can load it runs "execute()" and in this way lets me do useful things like monitor log files and so on.
I'm now revisiting the script to make it self documenting and it strikes me that perhaps there is a neater way of picking up these ad hoc classes; maybe a framework or nice example somewhere.
Can anyone suggest a neat solution? | 0 | python,plugins,adhoc | 2012-04-03T13:06:00.000 | 0 | 9,993,899 | You can simply import the modules (use the __import__ function), and reload them when they change.
Note that you will still have the issue that existing instances of classes will not automagically change to reflect the new class definition. | 0 | 134 | true | 0 | 1 | Can someone recommend a pythonic approach to loading adhoc code? | 9,993,949 |
1 | 2 | 1 | 0 | 4 | 0 | 0 | 0 | What is the most efficient way in terms of speed to access the pixel data of a PIL image from a C extension? I only need read-only access to it, if that makes a difference. | 0 | python,python-imaging-library,python-c-extension | 2012-04-03T15:06:00.000 | 0 | 9,996,105 | C-level bindings for PIL are available, but there is very little documentation for them. You will need to consult the source for usage information. | 0 | 456 | false | 0 | 1 | Accessing PIL image data from C extension | 9,996,422 |
1 | 2 | 1 | 1 | 0 | 0 | 1.2 | 0 | I am writing my own GUI with .NET (C#) and I want to use a python script to click buttons for me automatically and read from text boxes etc. I've tried the Google searches but nothing really helpful. Is there a library that I need to download for .NET or is there a module in python that will do what i"m looking for. I'm sure it can be done, I just don't know where yo start | 0 | c#,.net,python,user-interface | 2012-04-03T15:23:00.000 | 0 | 9,996,435 | It sounds like you might be looking for a test automation tool, to script GUI events. I looked into using Ranorex for that a while back, and it looked very capable, but it was too expensive and overkill for my needs. | 0 | 793 | true | 0 | 1 | Python script to control GUI? | 9,999,447 |
1 | 4 | 0 | 10 | 16 | 0 | 1.2 | 0 | Are there any tools which generate a project layout for python specific projects, much similar to what maven accomplishes with mvn archetype:generate for java projects. | 0 | python,maven | 2012-04-03T18:59:00.000 | 0 | 9,999,618 | It is the good news: you do not need any tool. You can organise your source code in any way you want.
Let recap why we need tools in the java world:
In java you want to generate directories upfront because the namespace system dictates that each class must live in one file in a directory structure that reflects that package hierarchy. As a consequence you have a deep folder structure. Maven enforces an additional set of convention for file location. You want to have tools to automate this.
Secondly, different artefacts require use of different goals and even additional maven projects (e.g. a ear project requires a few jars and war artefacts). There are so many files to create you want to have tools to automate this.
The complexity makes tools like mvn archetype:generate not just helpful. It is almost indispensable.
In python land, we just do not have these complexity in the language.
If my project is small, I can put all my classes and functions in a single file (if it makes sense)
If my project is of a bigger size (LOC or team size), it makes sense to group .py files into modules in whatever way makes sense to you and your peers.
At the end of the days, it is about striking a balance between ease of maintenance and readability. | 0 | 15,040 | true | 1 | 1 | Project structure for python projects with maven | 9,999,984 |
1 | 1 | 1 | 1 | 2 | 1 | 0.197375 | 0 | I'm having a problem with my (game) application, which is using Boost.Python, when it comes to the scripting part. I have a client thread and a server thread that runs in the same process if you do not connect to an external server.
This is where my problems arise: It seems like the Python interpreter can't execute scripts in the client thread parallel with scripts in the server thread, as it causes the application to crash.
So my question is: Is there any possibility to run two (or more) scripts parallel in the Python interpreter?
I have been searching all day and found a lot of information regarding Py_NewInterpreter, but this does not solve my problem as it uses GIL, I don't want the interpreter to lock other scripts from executing as it will cause lag on the client and/or the server side. | 0 | c++,parallel-processing,boost-python,cpython | 2012-04-03T20:04:00.000 | 0 | 10,000,524 | As of today, you cannot avoid GIL interactions when using python threads in the same process.
You may want to have a look at multiprocessing module which is meant to easily spawn Python processes, thus not interacting with GIL.
Another option is to explicitly release the GIL when its not needed in your wrapped C/C++ functions. This can be done using PyEval_SaveThread and PyEval_RestoreThread functions. | 0 | 624 | false | 0 | 1 | Running two python scripts parallel with boost::python | 10,002,004 |
1 | 1 | 0 | 2 | 0 | 0 | 0.379949 | 0 | I acquired a python script that will either telnet to some equipment, or if the equipment is in a lab, ssh to a firewall machine and then it will telnet to the equipment, and run a command, returning the output for more processing.
I took this script and tied it into a Django web app so that I could, from a browser, fill out a form with the target system info and have it display the results. If I start up this web app from the command line, and then access it from the browser (python manage.py app), everything works fine.
However, if I set this up to run in "production" mode, using a virtual host with Apache, the SSH fails. I suspect that this is running under root or some web account and cannot SSH to the firewall.
Can someone suggest how I get this to work? I don't have any privileges on the firewall machine, so I can't setup SSH to run under some web account.
Would I need to collect username and password from the user, in the case where SSH is used, and then pass it to ssh, or are there other ways to get the telnet info and command through to the equipment? | 0 | python,django,ssh | 2012-04-03T23:09:00.000 | 0 | 10,002,771 | You're close. The problem here is probably that your web server runs as a non-privileged user (NOT root), like www or www-data or nobody (depending on your operating system). While that user can probably run the SSH binary, when doing so as nobody, it probably doesn't have a home directory, can't find your .ssh directory, and can't find the key file (.ssh/id_rsa for example) that it needs to use for authentication.
You have a number of options. Make your private key available to the web server software, then launch ssh with the -i option to select an identity file. Or do this in an SSH config file that you specify with the -F option. Or launch ssh using sudo, and give your web server software the ability to run ssh as some other (shell) user.
I can't provide a more specific answer because you haven't provided specifics in your question. Operating system, sample code, etc.
Hope this helps.
Oh, and you should also consider NOT doing this, and finding some other solution. A web application, even an internal one, that has SSH access to your firewall? Sounds like a recipe for eventual disaster to me. :-) | 0 | 2,644 | false | 1 | 1 | need to ssh to remote machine from web page with python/django | 10,003,264 |
1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | I have a simple question. I am in the process of debugging some code. I am using Enthought Python, with the "PyLab" program. I edit my code using gEdit. I am using Ubuntu 10.04.4 LTS.
I use "run myfile.py" to run the program. Then I test myfile(somearguments), and see where the bugs are.
However, when I make changes to the code, using "run myfile.py" again does not properly update what Python/PyLab on the changes to my code. The result is that I will get error messages back pointing to lines that have no errors, and don't even have the "trouble" text in them anymore. I tried using import and reload as well, but that didn't work.
How do I get Python/PyLab to see the new changes to my code? The only option I have for now is to fix the bug and then restart PyLab to confirm the fix.
Thanks! | 0 | python,matplotlib | 2012-04-03T23:57:00.000 | 0 | 10,003,152 | Did you try to remove the pyc file ?
It may happen as the pyc file exists that PyLab keeps reading it without reloading the file. | 0 | 233 | false | 0 | 1 | Python "run" and "reload" not showing the changes to my code | 10,003,436 |
1 | 1 | 0 | 1 | 2 | 0 | 1.2 | 0 | I'm writing a Oracle of Bacon type website that involves a breadth first search on a very large directed graph (>5 million nodes with an average of perhaps 30 outbound edges each). This is also essentially all the site will do, aside from display a few mostly text pages (how it works, contact info, etc.). I currently have a test implementation running in Python, but even using Python arrays to efficiently represent the data, it takes >1.5gb of RAM to hold the whole thing. Clearly Python is the wrong language for a low-level algorithmic problem like this, so I plan to rewrite most of it in C using the Python/C bindings. I estimate that this'll take about 300 mb of RAM.
Based on my current configuration, this will run through mod_wsgi in apache 2.2.14, which is set to use mpm_worker_module. Each child apache server will then load up the whole python setup (which loads the C extension) thus using 300 mb, and I only have 4gb of RAM. This'll take time to load and it seems like it'd potentially keep the number of server instances lower than it could otherwise be. If I understand correctly, data-heavy (and not client-interaction-heavy) tasks like this would typically get divorced from the server by setting up an SQL database or something of the sort that all the server processes could then query. But I don't know of a database framework that'd fit my needs.
So, how to proceed? Is it worth trying to set up a database divorced from the webserver, or in some other way move the application a step farther out than mod_wsgi, in order to maybe get a few more server instances running? If so, how could this be done?
My first impression is that the database, and not the server, is always going to be the limiting factor. It looks like the typical Apache mpm_worker_module configuration has ServerLimit 16 anyways, so I'd probably only get a few more servers. And if I did divorce the database from the server I'd have to have some way to run multiple instances of the database as well (I already know that just one probably won't cut it for the traffic levels I want to support) and make them play nice with the server. So I've perhaps mostly answered my own question, but this is a kind of odd situation so I figured it'd be worth seeing if anyone's got a firmer handle on it. Anything I'm missing? Does this implementation make sense? Thanks in advance!
Technical details: it's a Django website that I'm going to serve using Apache 2.2.14 on Ubuntu 10.4. | 1 | python,database,django,apache,mod-wsgi | 2012-04-04T19:06:00.000 | 0 | 10,017,645 | First up, look at daemon mode of mod_wsgi and don't use embedded mode as then you can control separate to Apache child processes the number of Python WSGI application processes. Secondly, you would be better off putting the memory hungry bits in a separate backend process. You might use XML-RPC or other message queueing system to communicate with the backend processes, or even perhaps see if you can use Celery in some way. | 0 | 214 | true | 1 | 1 | Maximizing apache server instances with large mod_wsgi application | 10,020,054 |
1 | 1 | 0 | 5 | 3 | 1 | 1.2 | 0 | I'm not sure if I worded the subject correctly but essentially I'm curious if someone can develop code in the Python IDLE, or a similar tool, and then through some command spit out the current code in memory. I believe I did this previously when going through a Lisp book and recall it being a very different approach than the usual re-running of static files. Any suggestions as to how to do this or something similar? Thanks
UPDATE I ended up using a combination of the IDLE using execfile and reload commands, while editing code in a separate editor (eclipse/pydev). I changed my "main" file so that nothing executes immediately when execfile is called on it. Code in the main file and modules imported are loaded into the current scope/stack so as I'm writing new code or an error occurs I can test directly in the IDLE command line. Once I have found the problem or way forward I then update code in editor, run reload(module) for updated modules, then execfile(path) on the main file. | 0 | python,python-idle | 2012-04-05T15:22:00.000 | 0 | 10,031,427 | The reason why this is sensible with LISP is that every LISP programs is just a bunch of macros and functions and the s-expressions can be formatted automatically into a nice representation.
This isn't the case in Python, where you have more complex syntax (significant whitespace, decorators, lots of control structures, different types of string literals, ...) and more semantic elements (classes, functions, top-level code, ...), so this approach will not work very well here. The resulting code would get really messy for even the smallest of projects and the resulting code would still require a lot of "post-processing", somewhat annihilating the speed of development advantage.
Instead, you can just write the code in a good text editor and
Use built-in functionality to integrate it with the REPL (EMACS and Vim have good support for this kind of stuff) or
load it into REPL using execfile, which will give you the comfort of good text editing and the interactivity of the prompt.
along with the program, write a suite of unit tests. This is to be recommended for any non-trivial piece of software and automates the testing of your code, so you'll have to spend less time in an interactive prompt, manually checking if a function works correctly.
You could also grab a more fully-featured IDE that supports code evaluation and full-blown debugging (PyDev is an example here, thanks to sr2222). | 0 | 199 | true | 0 | 1 | Can a python IDLE be used for iterative/in-memory development? | 10,031,501 |
1 | 1 | 0 | 1 | 2 | 0 | 1.2 | 0 | I have a call to a python script that is sudo -u user_name python python_scipt.py and I need to schedule it to run every 30 minutes with crontab. The problem is how can I authenticate it with sudo on crontab? | 0 | python,crontab | 2012-04-05T17:19:00.000 | 1 | 10,033,057 | Everything solved with the sudo crontab -u username -e
credits to 9000 | 0 | 489 | true | 0 | 1 | Authenticate with sudo on a crontab job | 10,198,435 |
2 | 4 | 0 | 0 | 2 | 1 | 0 | 0 | I need to separate natural, coherent text/sentences in emails from lists, signatures, greetings and so on before further processing.
example:
Hi tom,
last monday we did bla bla, lore Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et
dolore magna aliqua.
list item 2
list item 3
list item 3
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid x ea commodi consequat. Quis aute iure reprehenderit
in voluptate velit
regards, K.
---line-of-funny-characters-#######
example inc.
33 evil street, london
mobile: 00 234534/234345
Ideally the algorithm would match only the bold parts.
Is there any recommended approach - or are there even existing algorithms for that problem? Should I try approximate regular expressions or more statistical stuff based on number of punctation marks, length and so on? | 0 | python,regex,algorithm,nlp | 2012-04-06T16:44:00.000 | 0 | 10,046,451 | You'll need many heuristics to get an approximation of a solution, so here's one: you can safely cut off anything after a sigdash (hyphen-hyphen-space), which standards-conforming e-mail messages use to separate the message body from the signature.
Another approach you can use is to store copies of e-mails from the same sender; this should allow you to extract things that are the same or similar in every message (such as salutations and signatures) and detect how their mail client does quoting. | 0 | 229 | false | 0 | 1 | Algorithm to match natural text in mail | 10,047,362 |
2 | 4 | 0 | 3 | 2 | 1 | 0.148885 | 0 | I need to separate natural, coherent text/sentences in emails from lists, signatures, greetings and so on before further processing.
example:
Hi tom,
last monday we did bla bla, lore Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et
dolore magna aliqua.
list item 2
list item 3
list item 3
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid x ea commodi consequat. Quis aute iure reprehenderit
in voluptate velit
regards, K.
---line-of-funny-characters-#######
example inc.
33 evil street, london
mobile: 00 234534/234345
Ideally the algorithm would match only the bold parts.
Is there any recommended approach - or are there even existing algorithms for that problem? Should I try approximate regular expressions or more statistical stuff based on number of punctation marks, length and so on? | 0 | python,regex,algorithm,nlp | 2012-04-06T16:44:00.000 | 0 | 10,046,451 | In the example you post, line length suffices.
There is no perfect algorithm; even human beings will classify lines differently.
I suggest just use line length until you find a counter example, at which point revise your algorithm. Repeat until problem solved to your satisfaction. | 0 | 229 | false | 0 | 1 | Algorithm to match natural text in mail | 10,046,551 |
1 | 3 | 0 | 2 | 1 | 1 | 0.132549 | 0 | I have a need to identify comments in different kinds of source files in a given directory. ( For example java,XML, JavaScript, bash). I have decided to do this using Python (as an attempt to learn Python). The questions I have are
1) What should I know about python to get this done? ( I have an idea that Regular Expressions will be useful but are there alternatives/other modules that will be useful? Libraries that I can use to get this done?)
2) Is Python a good choice for such a task? Will some other language make this easier to accomplish? | 0 | python,text-manipulation | 2012-04-06T17:03:00.000 | 0 | 10,046,665 | 1) What you need to know about is parsing, not regex. Additionally you will need the os module and some knowledge about pythons file handling. DiveIntoPython (http://www.diveintopython.net/) is a good start here. I'd recommend chapter 6. (And maybe 1-5 as well :) )
2) Python is a good start. Another language is not going to make it easier, but different. Python allready is pretty simple to start with.
I would recommend not to use regex for your task, as it is as simple as searching for comment signs and linefeeds. | 0 | 104 | false | 0 | 1 | What should I know about Python to identify comments in different source files? | 10,046,888 |
1 | 1 | 0 | 0 | 3 | 0 | 0 | 0 | This is my first hack at doing any system-level programming (mostly a LAMPhp, specifically Drupal, web dev up to this point).
Because of availability of a library with a very specific feature, I am using Python for an upcoming project. I need to run, restart as needed, monitor and respond to the output of multiple Python script processes, controlled ideally via a HTTP API from another master program which keeps a database of processes that need to be running, and some metadata about those processes (parameters, pid, etc). I'm planning on building this master program in PHP as I have far more experience in it, hence the want for a nice HTTP API.
Is there some best practice for this type of system? Some initial research lead me to supervisord (which has XML-RPC built in, apparently), but I thought I'd check the wisdom of the masses who've actually been down this road before moving forward with testing. | 0 | python,web-services,architecture,operating-system | 2012-04-07T16:37:00.000 | 0 | 10,056,289 | I can't say I have been down this road, but I am working to go down this road. I would look into the multiprocessing libraries for Python. There are network transparent libraries. A couple of routes you could take with those:
1. Create a process that controls all of the other processes. Make this process a server you can control with your PHP.
2. Determine how to get PHP to communicate to these networked Python processes. They may still need to be launched from a central Python process however. | 0 | 875 | false | 0 | 1 | Best practice for Python process control | 10,711,768 |
1 | 2 | 0 | 3 | 8 | 1 | 0.291313 | 0 | I'm wondering if there's a speedy, Pythonic way to calculate factorials of non-integral numbers (e.g., 3.4)? Of course, the bult-in factorial() function in the Math module is available, but it only works for integrals (I don't care about negative numbers here). | 0 | python,floating-point,factorial | 2012-04-07T17:45:00.000 | 0 | 10,056,797 | In Python 2.7 or 3.2, you can use math.gamma(x + 1). In older versions, you'd need some external library like SciPy. | 0 | 7,874 | false | 0 | 1 | Python: Calculate factorial of a non-integral number | 10,056,813 |
3 | 4 | 0 | 0 | 1 | 0 | 0 | 1 | I am trying to build a simple email client with python and IMAPClient. The problem is that the folder names aren't uniform for all servers.
If i mark an e-mail as spam, it has to be moved to the spam/junk folder from the inbox folder (?) .. but i am unable to do that because i don't know what the folder name would be (Spam or INBOX.junk or [Gmail]/Spam )
How do other email clients work with varying folder names ? | 0 | python,email,imap | 2012-04-08T17:24:00.000 | 0 | 10,064,769 | They try a lot of possibilities, let you choose one and/or create one ;) | 0 | 1,797 | false | 0 | 1 | Identifying IMAP mail folders (spam,sent...), folder names vary with servers | 10,064,803 |
3 | 4 | 0 | 0 | 1 | 0 | 0 | 1 | I am trying to build a simple email client with python and IMAPClient. The problem is that the folder names aren't uniform for all servers.
If i mark an e-mail as spam, it has to be moved to the spam/junk folder from the inbox folder (?) .. but i am unable to do that because i don't know what the folder name would be (Spam or INBOX.junk or [Gmail]/Spam )
How do other email clients work with varying folder names ? | 0 | python,email,imap | 2012-04-08T17:24:00.000 | 0 | 10,064,769 | Roundcube have this in both the server and user configuration. I don't know about other mail clients, but I guess they either use heuretics, either by just looking at what folders there are or by using knowledge about the particular IMAP server. | 0 | 1,797 | false | 0 | 1 | Identifying IMAP mail folders (spam,sent...), folder names vary with servers | 10,064,809 |
3 | 4 | 0 | 2 | 1 | 0 | 1.2 | 1 | I am trying to build a simple email client with python and IMAPClient. The problem is that the folder names aren't uniform for all servers.
If i mark an e-mail as spam, it has to be moved to the spam/junk folder from the inbox folder (?) .. but i am unable to do that because i don't know what the folder name would be (Spam or INBOX.junk or [Gmail]/Spam )
How do other email clients work with varying folder names ? | 0 | python,email,imap | 2012-04-08T17:24:00.000 | 0 | 10,064,769 | I believe that for common EMail providers they have a mapping as to what that provider uses by default (gmail, hotmail, exchange etc.).
Another way of doing it is to let the user decide first time, persist the setting for that account and not ask again.
Mixed approach would be to try and detect all common variations and use the first valid one you encounter. If there are more then one simply allow user to choose. | 0 | 1,797 | true | 0 | 1 | Identifying IMAP mail folders (spam,sent...), folder names vary with servers | 10,064,811 |
1 | 3 | 0 | 0 | 0 | 1 | 0 | 0 | I wrote a sorting algorithm in python.
It returns a Python Dictionary object.
How do i get the dictionary from Python into my PHP code as an associative arr ?
Will I have to write the whole sorting algorithm again in PHP? | 0 | php,python,python-2.7 | 2012-04-09T11:06:00.000 | 0 | 10,072,287 | What you can do is save the Dictionary Object as json or xml in Python, then use json_decode or simple_xml in PHP to load it as array or object
You need no sorting algorithm ... PHP has a lot of them | 0 | 3,027 | false | 0 | 1 | Converting a Python Dictionary into Associative Array for PHP | 10,072,364 |
1 | 2 | 0 | 1 | 1 | 0 | 0.099668 | 0 | I have to build a web application which uses Python, php and MongoDB.
Python - For offline database populating on my local home machine and then exporting db to VPS. Later I am planning to schedule this job using cron.
PHP - For web scripting.
The VPS I wish to buy supports Python and LAMP Stack but not mongoDB (myhosting.com LAMP stack VPS) by default. Now since mongoDB isn't supported by default, I would have to install mongoDB manually on VPS. So what I want to know is that, had it been my VPS would have supported mongoDB would I have benefitted in terms of performance and scalability.
Also can someone please suggest a VPS suitable in my case. | 1 | php,python,mongodb,vps | 2012-04-09T13:28:00.000 | 0 | 10,073,934 | If the vps you are looking at restricts the packages you can install, and you need something that they prohibit, I would look for another vps. Both rackspace and amazon a range of instances, and numerous supported os. With either of them you choose your operating system and are free to install whatever you want. | 0 | 810 | false | 0 | 1 | Performance of MongoDB on VPS or cloud service not having mongoDB installed | 10,074,035 |
1 | 1 | 0 | 1 | 0 | 1 | 0.197375 | 0 | I am using the email module and creating a message object out of both ASCII and Unicode files that are essentially emails.
The emails include a secretary responding in one portion and in others the boss creating the email. These emails were extracted from pst files (i.e. from outlook or something similar). If you are familiar with company emails then you'll know what I'm talking about.
Also if do have multiparts and I use get_payload() on those parts and specify an index, i, how are the indices arranged? As in what is in the indices? Are they the parts of an email? | 0 | python,email,message,multipart,smtplib | 2012-04-10T04:03:00.000 | 0 | 10,082,968 | A multipart message is basically a nested e-mail message. The embedded messages are ordered in the order that the messages were attached to the containing e-mail. There isn't and index embedded in the e-mail (if I understand your question correctly) - get_payload() would return a list of the embedded e-mail messages.
If you saw the raw e-mail and how the MIME parts are arranged it would clarify your understanding. | 0 | 287 | false | 0 | 1 | What exactly is a python sub message object if is_multipart is true and how does python organize them? | 13,021,872 |
2 | 3 | 0 | 3 | 12 | 1 | 0.197375 | 0 | I am trying to understand few things with respect to design.
I see a number of the code where Lazy Import features is used.By Lazy Import, I mean a facility provided by certain recipes, packages and modules which support "LazyImport" style. Those implementation in general aim to import the module only when it is used and provide some extra hooks for different things. I know there the error condition is delayed over here, but I am trying to understand why Lazy Import is not a default strategy in Python.
What could it's (other) drawbacks be which prevent it from making a general useful case. Or are there languages which use this as a default import mechanism strategy. | 0 | python | 2012-04-10T07:05:00.000 | 0 | 10,084,487 | Sometimes modules do important things when they are first loaded, so it might break the program to delay import of the module. For example, if a module defines command-line flags that should be parsed when the program first starts, the module must be imported before parsing the arguments. Since Python was originally designed to do imports eagerly, it's not possible to change the default behavior now without breaking some existing programs. Also, as mentioned in some of the other answers, for long-running services it's often desirable to load everything up front before serving requests so that the first few requests are not slowed down waiting for modules to be imported. | 0 | 5,844 | false | 0 | 1 | Why Lazy Import is not default in Python? | 30,221,189 |
2 | 3 | 0 | 5 | 12 | 1 | 0.321513 | 0 | I am trying to understand few things with respect to design.
I see a number of the code where Lazy Import features is used.By Lazy Import, I mean a facility provided by certain recipes, packages and modules which support "LazyImport" style. Those implementation in general aim to import the module only when it is used and provide some extra hooks for different things. I know there the error condition is delayed over here, but I am trying to understand why Lazy Import is not a default strategy in Python.
What could it's (other) drawbacks be which prevent it from making a general useful case. Or are there languages which use this as a default import mechanism strategy. | 0 | python | 2012-04-10T07:05:00.000 | 0 | 10,084,487 | Python, unlike e.g. PHP, is rarely used in a way where every request/action/... causes the whole application to be started again.
So importing everything at startup has the advantage of not having to perform imports while the application is doing something where delays are annoying.
The only advantage of local/lazy imports is that you won't have problems with circular imports. | 0 | 5,844 | false | 0 | 1 | Why Lazy Import is not default in Python? | 10,084,940 |
1 | 1 | 0 | 1 | 0 | 1 | 1.2 | 0 | I'm building a scientific/education application, and I need to provide power-user scripting capabilities. My choices are:
Embedding an existing language such as Python or Lua
Or creating my own language with coco/R, for example
(Initially I'm building in C#, but will probably later port to C++ for iPad & Android reach.)
Each approach has its advantages, but a big factor is that I don't want to be shut out of app stores. Apple apparently prohibits apps that run interpreted code. I don't really understand how this is defined - surely any app runs by interpreting its own data structures? I assume it's some sort of "we know pornography when we see it" definition, and you just mustn't make your system look too powerful. If this is the case, I'm thinking that if I build my own language and transmit only the active syntax tree and not the scripting source, then I'm less likely to trigger their alarm bells - it'll look like any old data structure. Anyone know if this is right? | 0 | c#,python,lua | 2012-04-10T12:22:00.000 | 0 | 10,088,731 | Apple relaxed the language in their license agrement to allow Lua a few years ago. It's used in a huge number of iOS games (including Angry Birds, all EA games, etc.). In fact, there are many games on the App Store written in Lua, using Lua-based frameworks like Corona or MOAI (such as Crimson: Steam Pirates, a Bungie Aerospace funded game which was #1 on the App Store for a few weeks). There are also Apps like Codea, a Lua scripting environment that end users can use to build games/toys right on the device. Lua is very popular on the iOS platform.
Creating your own language would be absurd, IMO. Lua is too good, and a perfect fit for iOS: light weight, fast, hackable, user friendly, easily embedded and extended, etc. However, you may have trouble integrating it into a C# app. I don't really know how MonoTouch works, but in the desktop world, C# is managed code, compiled to byte code, but Lua's API is native code. Bridging that gap can be done, but it's more work.
In short, you can use Lua and you don't have to hide it. What you're not allowed to do is create a "metaplatform", where users can basically download entirely new applications (which have not been reviewed by Apple) through your app.
EDIT: Regarding "I'm building in C#, but will probably later port to C++ for iPad & Android reach", you may want to check out MOAI. It's an open source, cross platform (PC, Mac, iPad, Android, Chrome) framework written in C++ for writing games in Lua. Might save you time to start there rather than porting later. You can do pretty much everything directly in Lua, and if you run into something where you need bare-metal performance or access to functionality not already exposed via a Lua API, you can write it in C or C++. | 0 | 360 | true | 0 | 1 | Embedded scripting on the AppStore - use Python, or snake my way in? | 10,145,095 |
1 | 1 | 0 | 1 | 2 | 0 | 0.197375 | 0 | I'm developing a framework of sorts. I'm providing a base class, that will be subclassed by other developers to add behavior to the system. The instances of those classes will have attributes that my framework doesn't necessarily expect, except by inspecting those instances' __dict__. To make things even more interesting, some of those classes can be created dynamically, at any time.
I'd like some things to be handled by the framework, namely, I will need to persist those instances, display their attribute values to the user, and let her search/filter instances using those values.
I have to use a relational database. I know there are some decent python OO database out there, but unfortunately they're not an option in this case.
I'm not looking for a full-blown ORM too... and it may not even be an option, given that some of the classes can be created dynamically.
So, my question is, what state of a python instance do I need to serialize to ensure that I can deserialize it later on? Is it enough to look at __dict__, or are there other private attributes that I should be using?
Pickling the instances is not enough, because I'll need to unpickle them to search/filter the attribute values, and I'm afraid it's too much data to do it in-memory (instead of letting the database do it). | 0 | python,metaprogramming,pickle | 2012-04-10T18:18:00.000 | 0 | 10,094,217 | Just use an ORM. This is what they are for.
What you are proposing to do is create your own half-assed ORM on your own time. Save your time for your own code that does things, and use the effort other people put for free into solving this problem for you.
Note that all class creation in python is "dynamic" - this is not an issue, for, well, anything at all. In fact, if you are assembling classes programmatically, it is probably slightly easier with an ORM, because they provide reifications of fields.
In the worst case, if you really do need to store your objects in a fake nosql-type schema, you will still only have to write your own backend driver if you use an existing ORM, rather than coding the whole stack yourself. (As it happens, you're not the first person to face this - solutions exist. Goole "python orm store dynamically created models" and "sqlalchemy store dynamically created models")
Candidates include:
Django ORM
SQLAlchemy
Some others you can find by googling "Python ORM". | 0 | 136 | false | 1 | 1 | Getting and serializing the state of dynamically created python instances to a relational model | 10,094,298 |
1 | 5 | 0 | 1 | 20 | 0 | 0.039979 | 0 | I have a R data.frame containing longitude, latitude which spans over the entire USA map. When X number of entries are all within a small geographic region of say a few degrees longitude & a few degrees latitude, I want to be able to detect this and then have my program then return the coordinates for the geographic bounding box. Is there a Python or R CRAN package that already does this? If not, how would I go about ascertaining this information? | 0 | python,r,geolocation,cran | 2012-04-11T14:47:00.000 | 0 | 10,108,368 | A few ideas:
Ad-hoc & approximate: The "2-D histogram". Create arbitrary "rectangular" bins, of the degree width of your choice, assign each bin an ID. Placing a point in a bin means "associate the point with the ID of the bin". Upon each add to a bin, ask the bin how many points it has. Downside: doesn't correctly "see" a cluster of points that stradle a bin boundary; and: bins of "constant longitudinal width" actually are (spatially) smaller as you move north.
Use the "Shapely" library for Python. Follow it's stock example for "buffering points", and do a cascaded union of the buffers. Look for globs over a certain area, or that "contain" a certain number of original points. Note that Shapely is not intrinsically "geo-savy", so you'll have to add corrections if you need them.
Use a true DB with spatial processing. MySQL, Oracle, Postgres (with PostGIS), MSSQL all (I think) have "Geometry" and "Geography" datatypes, and you can do spatial queries on them (from your Python scripts).
Each of these has different costs in dollars and time (in the learning curve)... and different degrees of geospatial accuracy. You have to pick what suits your budget and/or requirements. | 1 | 5,580 | false | 0 | 1 | Detecting geographic clusters | 10,108,983 |
1 | 1 | 0 | 2 | 1 | 0 | 1.2 | 0 | If I am using a python script with mechanize to fill out forms on websites (such as login information) should I be worried about encryption? Is there anything I need/could do to ensure that the password sent is encrypted? (Or is this even necessary? Is filling out a form with mechanize equivalent to filling out a form with a standard web browser and therefore there I am not actually "sending" anything (ie. its up to the website to use https)).
Thanks!
Alex | 0 | python,encryption,https,mechanize,mechanize-python | 2012-04-11T16:15:00.000 | 0 | 10,109,848 | It's exactly the same as using a web browser -- you should use the same judgement as to whether you want to enter your username and password. | 0 | 215 | true | 0 | 1 | Python Mechanize Module Encryption | 10,109,960 |
1 | 2 | 0 | 1 | 17 | 1 | 0.099668 | 0 | I'm dynamically defining functions in a module and then updating the module's __all__ and the function's __name__ attribute to match the name it will have inside the module. I was wondering if it is a good idea to update the function's __module__ attribute as well to point to the module the function will reside. The docs say __module__ is:
The name of the module the function was defined in, or None if unavailable.
The code that creates the function resides in a different module which is pretty much unrelated to the module where the function resides. There is no reference to the function in this module.
I've done some poking around on the mailing list but I'm a bit confused as to what the semantics of __module__ are and if I should set it to None or the module that the function resides or the module where the code resides that created the function. Gonna leave it be for now but am interested to see if anyone knows the answer. | 0 | python | 2012-04-11T20:58:00.000 | 0 | 10,113,892 | You shouldn't have to worry about __module__ usually, sometimes its used for dark magic or knowing where a function came (example) debugging from, but most of the time everyone ignores it. If your really worried set __module__ = "dynamically_defined_function" or something similar. | 0 | 22,298 | false | 0 | 1 | semantics of __module__ | 10,114,026 |
1 | 1 | 0 | 2 | 3 | 0 | 1.2 | 0 | compared to invoking a python library function that does the same thing.
I've some legacy code that uses Popen to invoke a executable with some parameters.
Now there a python library that supports that same function.
I was wondering what the performance implications are. | 0 | python,native,popen | 2012-04-12T02:25:00.000 | 1 | 10,116,602 | Forking a separate process to do something is almost always much more expensive than calling a function that does the same thing. But if that Python function is very inefficient, and the OS forks new processes quickly (i.e., is a UNIX variant,) you could imagine a rare case where this is not true -- but it will definitely be rare. | 0 | 601 | true | 0 | 1 | What is the performance overhead of Popen in python | 10,116,621 |
1 | 5 | 0 | 0 | 6 | 0 | 0 | 0 | I am reading data from a microcontroller via serial, at a baudrate of 921600. I'm reading a large amount of ASCII csv data, and since it comes in so fast, the buffer get's filled and all the rest of the data gets lost before I can read it. I know I could manually edit the pyserial source code for serialwin32 to increase the buffer size, but I was wondering if there is another way around it?
I can only estimate the amount of data I will receive, but it is somewhere around 200kB of data. | 0 | python,serial-port,pyserial | 2012-04-12T13:53:00.000 | 0 | 10,125,009 | For me the problem was it was overloading the buffer when receiving data from the Arduino.
All I had to do was mySerialPort.flushInput() and it worked.
I don't know why mySerialPort.flush() didn't work. flush() must only flush the outgoing data?
All I know is mySerialPort.flushInput() solved my problems. | 0 | 12,564 | false | 0 | 1 | Pyserial buffer fills faster than I can read | 67,317,060 |
1 | 2 | 0 | 0 | 1 | 0 | 0 | 0 | I'm in the process of migrating my Google AppEngine solution from Python 2.5 to 2.7. The application migration was relatively easy, but I'm struggling with the unittests.
In the 2.5 version I was using the use_library function to set the django version to 1.2, but this isn't supported anymore on 2.7. Now I set the default version in the app.yaml.
When I'm now running my unittests the default django version becomes 0.96 and I can't manage to set the 1.2 as the default version.
Who knows how I can set the default libraries for the unittest, so the match the settings in the app.yaml? | 0 | unit-testing,google-app-engine,python-2.7 | 2012-04-12T14:38:00.000 | 1 | 10,125,860 | app.yaml configuration is not applied when doing unit tests with webtest app and NoseGAE.
use_library does not work neither.
The right solution for this case is to provide proper python path to the preferred lib version, e.g. PYTHONPATH=../google_appengine/lib/django-1.5 when running nosetests. | 0 | 111 | false | 1 | 1 | How to set the default libraries when doing unit tests under Python 2.7 | 21,678,252 |
1 | 2 | 0 | 0 | 0 | 0 | 0 | 1 | I have a cgi script wrote in Python that is receiving some complex http request, one that could be POST or GET.
I am looking for a simple way to log the request in some way so I can replay it later any number of times I want. | 0 | python,http,cgi | 2012-04-12T20:44:00.000 | 0 | 10,131,506 | Seems you're looking to cache queries made to your site.
After calculating a response, save a record with the request url, method, params, and response in a your preferred storage.
Depending on your environment and the number of requests, your may choose a database or filesystem.
However, you need to take into account that some of the result data may change, in which case you'd need to remove cached data that depend on that data. | 0 | 91 | false | 0 | 1 | How can I save a HTTP request from a python cgi scripts so I can easily repeat it? | 40,729,146 |
1 | 6 | 0 | 20 | 40 | 1 | 1 | 0 | I am using pydev where I have set up pylint.
The problem is that even inside the comments, pylint reports warnings. I was looking to disable any sort of checking inside any line or a block comment.
Also, I wish to follow camelCase naming convention instead of underscores for variables and arguments in my code.
Is there any way to specify such a rule without inserting my code with any pylint: disable comments? | 0 | python,pydev,pylint | 2012-04-13T10:08:00.000 | 0 | 10,138,917 | As said by cfedermann, you can specify messages to be disabled in a ~/.pylintrc file (notice you can generate a stub file using pylint --generate-rcfile if you don't want to use inline comments.
You'll also see in the generated file, in the [BASIC] section, options like "method-rgx", "function-rgx", etc. which you can configure as you like to support camel cases style rather than pep8 underscore style. | 0 | 33,391 | false | 0 | 1 | Can Pylint error checking be customized? | 10,140,373 |
1 | 4 | 0 | 3 | 4 | 0 | 0.148885 | 0 | I stepped into python gui programming and I wanted to know what the best documented GUI builder like GLADE, which I'm using right now, however I struggle so much to find some good tutorials or documentation, mostly in the even handling area.
I would like also to understand what's the best/documented GUI framework.
Thanks to anyone who will answer. | 0 | python,user-interface,pyqt,pygtk,glade | 2012-04-13T12:11:00.000 | 0 | 10,140,560 | There is no "best/documented GUI framework". There are many GUI toolkits, all more-or-less equally powerful. Tkinter, PyQT, wxPython... all have their strengths and weaknesses. Pick any one of them and start learning.
I recommend Tkinter for learning, mainly because you probably already have it. Once you understand the fundamentals of event based programming (and Tkinter provides a fairly gentle way to learn that), you'll be in a better position to judge which of the available toolkits fits your definition of "best". | 0 | 6,486 | false | 0 | 1 | what the best documented python friendly GUI builder like GLADE | 10,141,980 |
1 | 3 | 0 | 1 | 1 | 1 | 0.066568 | 0 | Okay, so I probably shouldn't be worrying about this anyway, but I've got some code that is meant to pass a (possibly very long, possibly very short) list of possibilities through a set of filters and maps and other things, and I want to know if my implementation will perform well.
As an example of the type of thing I want to do, consider this chain of operations:
get all numbers from 1 to 100
keep only the even ones
square each number
generate all pairs [i, j] with i in the list above and j in [1, 2, 3, 4,5]
keep only the pairs where i + j > 40
Now, after doing all this nonsense, I want to look through this set of pairs [i, j] for a pair which satisfies a certain condition. Usually, the solution is one of the first entries, in which case I don't even look at any of the others. Sometimes, however, I have to consume the entire list, and I don't find the answer and have to throw an error.
I want to implement my "chain of operations" as a sequence of generators, i.e., each operation iterates through the items generated by the previous generator and "yields" its own output item by item (a la SICP streams). That way, if I never look at the last 300 entries of the output, they don't even get processed. I known that itertools provides things like imap and ifilter for doing many of the types of operations I would want to perform.
My question is: will a series of nested generators be a major performance hit in the cases where I do have to iterate through all possibilities? | 0 | python,generator | 2012-04-13T15:19:00.000 | 0 | 10,143,637 | "Nested" iterators amount to the composition of the functions that the iterators implement, so in general they pose no particularly novel performance considerations.
Note that because generators are lazy, they also tend to cut down on memory allocation as compared with repeatedly allocating one sequence to transform into another. | 1 | 1,253 | false | 0 | 1 | How fast are nested python generators? | 10,144,447 |
1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | How to call a phone number using gsm & python. i have try many software in window, but i can't found it using python. | 0 | python | 2012-04-14T08:55:00.000 | 0 | 10,152,317 | You should open a COM serial port to the gsm modem from python and use AT commands, search Wikipedia for those, they are used to communicate with gsm devices | 0 | 1,039 | false | 0 | 1 | How to call a phone number using gsm & python | 10,152,343 |
1 | 1 | 0 | 1 | 1 | 0 | 0.197375 | 0 | My python application sits behind an Nginx instance. When I upload an image, which is one of the purpose of my app, I notice that nginx first saves the image in filesystem (used 'watch ls -l /tmp') and then hands it over to the app. Can I configure Nginx to work in-memory with image POST? My intent is to avoid touching the slow filesystem (the server runs on an embedded device). | 0 | python,image,nginx | 2012-04-14T23:05:00.000 | 1 | 10,158,096 | Yes, set the proxy_max_temp_file_size to zero, or some other reasonably small value. Another option (which might be a better choice) is to set the proxy_temp_path to faster storage so that nginx can do a slightly better job of insulating the application from buggy or malicious hosts. | 0 | 673 | false | 1 | 1 | Nginx: Speeding up Image Upload? | 10,165,928 |
1 | 3 | 0 | 1 | 6 | 0 | 1.2 | 0 | I have a video encoding script that I would like to run as soon as a file is moved into a specific directory.
If I use something like inotify, how do I ensure that the file isn't encoded until it is done moving?
I've considered doing something like:
Copy (rsync) file into a temporary directory.
Once finished, move (simple 'mv') into the encode directory.
Have my script monitor the encode directory.
However, how do I get step #2 to work properly and only run once #1 is complete?
I am using Ubuntu Server 11.10 and I'd like to use bash, but I could be persuaded to use Python if that'd simplify issues.
I am not "downloading" files into this directory, per se; rather I will be using rsync the vast majority of the time.
Additionally, this Ubuntu Server is running on a VM.
I have my main file storage mounted via NFS from a FreeBSD server. | 0 | python,bash,ubuntu,file-monitoring | 2012-04-15T16:35:00.000 | 1 | 10,163,877 | One technique I use works with FTP. You issue a command to the FTP server to transfer the file to an auxiliary directory. Once the command completes, you send a second command to the server, this time telling it to rename the file from from the aux directory to the final destination directory.If you're using inotify or polling the directory, the filename won't appear until the rename has completed, thus, you're guaranteed that the file is complete.
I'm not familar with rsync so I don't know if it has a similar rename capability. | 0 | 1,292 | true | 0 | 1 | Move file to another directory once it is done transferring | 10,176,476 |
1 | 2 | 0 | 0 | 0 | 0 | 0 | 0 | zc.recipe.egg allows you to install any egg and its script with buildout.
However, zc.recipe.egg relies on find-links and index behavior, inherit from setuptools I guess. It would like to take an egg server / HTML for scanning.
What if I just want to point zc.recipe.egg to a egg direct download URL how would I do that? Looks like putting it to find-links is no go. | 0 | python,buildout | 2012-04-15T19:34:00.000 | 0 | 10,165,342 | Putting it in find-links should work. I've done that in the past. You have to make sure the link is of the correct format as any python egg. | 0 | 748 | false | 0 | 1 | Buildout and zc.recipe.egg - specifying egg download URL directly? | 10,168,036 |
2 | 3 | 0 | 2 | 1 | 1 | 1.2 | 0 | PHP uses __construct() to set properties for a newly created object. From what I understand, it's not really a constructor, but a method. Why?
Also - for less .. inconsistent languages like Java or Python does the object gets instantiated before or after the constructor is called? And how is this different from the PHP way?
Thanks! | 0 | java,php,python,constructor | 2012-04-16T01:57:00.000 | 0 | 10,167,900 | Both of those languages instantiate it before calling the constructor. In Java, you have access to this, in Python self. Also, in Java, it's like a method, except with no return type. In Python, the syntax is exactly that of a method (__init__). | 0 | 244 | true | 0 | 1 | Why is the PHP constructor a method? | 10,167,913 |
2 | 3 | 0 | 0 | 1 | 1 | 0 | 0 | PHP uses __construct() to set properties for a newly created object. From what I understand, it's not really a constructor, but a method. Why?
Also - for less .. inconsistent languages like Java or Python does the object gets instantiated before or after the constructor is called? And how is this different from the PHP way?
Thanks! | 0 | java,php,python,constructor | 2012-04-16T01:57:00.000 | 0 | 10,167,900 | In every object-oriented language (that I know of; I'm hardly an expert in all of them), the constructor is called after the object is created, to initialise the contents of the object. No code in the constructor creates the object, or can in anyway influence the creation process[1].
(Note I don't refer to memory; in languages like C++ and Java "the object has been created" means the memory its fields occupy has been allocated, whereas in Python "the object has been created" means there is a dictionary that will hold attributes of the object once they are assigned)
In most OO languages that I know of, constructors also have extremely similar syntax to methods, and I don't see any conceptual difficulty in thinking about them as methods in most senses (in Python the __init__ method is literally a method in every sense; there's just a protocol that the runtime system invokes it on new objects after they're created).
[1]Python has additionally a feature that does let you control the object creation process; but you don't do it with the __init__ method (the special method that most closely corresponds with constructors from Java/PHP), you do with with __new__. | 0 | 244 | false | 0 | 1 | Why is the PHP constructor a method? | 10,169,430 |
1 | 3 | 0 | 1 | 6 | 1 | 0.066568 | 0 | I'm looking for a way to have a GitPoller changesource watch all branches instead of just one.
For now, either I specify branch='some branch' in the GitPoller constructor, or it defaults to master.
Even better would be to be able to specify some ref pattern to watch.
Is that something one does already? Or does it need to code another kind of GitPoller ?
Thanks. | 0 | python,git,continuous-integration,buildbot | 2012-04-16T05:55:00.000 | 0 | 10,169,290 | Currently GitPoller can only watch a single branch at a time. However, you can have as many GitPollers as you want. | 0 | 2,319 | false | 0 | 1 | How to have a buildbot GitPoller change source watch all branches? | 10,268,147 |
1 | 3 | 0 | 1 | 4 | 0 | 0.066568 | 1 | All the forks of gevent-socketio in bitbucket and github have examples/chat.py that do not work.
Can anyone find me a working example of gevent-socketio? | 0 | python,websocket,socket.io,gevent | 2012-04-18T06:46:00.000 | 0 | 10,204,230 | what browser do you use. I saw this behavior with IE. both Mozilla and chrome were fine. there were issues with the flashscket protocol which I have fixed so ie should work but the jquery UI does not work that is the issue. don't know enough JS to fix it | 0 | 7,663 | false | 0 | 1 | Do anyone have a working example of gevent-socketio? | 11,271,531 |
2 | 2 | 1 | 2 | 3 | 1 | 1.2 | 0 | I am working on a design of an application. The Core should be written in C# but i also want to use some already finished CPython modules (un-managed).
So I am interested in the interoperability (Call CPython method from C# and Call C# from CPython). And if there are problems, because C# runs within the .NET runtime (managed) and CPython directly un-managed.
I already investigated this issue with Google and came out to these solutions:
Use IronPython via DLR + "CPython extension" + maybe "IronClad" and call from IronPython the CPython modules and vice versa -> are these modules executed managed or unmanaged ? Are There any problems if i want to use C# classes and methods from CPython ?
Use "Python for .NET" -> the same question as above.
What do you think, which way would be better ? or do you have another solution ?
And the last but maybe most important question, did I understand the above mentioned points right, or do I mess up ?
Many thanks in advance !! | 0 | c#,.net,python,interop,ironpython | 2012-04-18T12:02:00.000 | 0 | 10,208,960 | I think you misunderstand Python. It's an interpreted1 language. You just provide the text source files and the interpreter will execute them.
There is a difference between the language Python and the implementations CPython, IronPython, Jython, PyPy, what have you. Each of them attempts to implement the language Python as accurately as possible, while also adding implementation-specific functionality. This is just like how, say, the C# compiler was written in C++.
For example, any (pure) Python file can be executed by the IronPython interpreter. But if you know that you're going to use IronPython, you can use the special IronPython features that let you into the .NET library.
Now, most Python doesn't use any of the implementation-specific functionality, so it doesn't matter what you use to run it. Some Python does, though.
1Well, it's compiled into .pyc files... but then "compile" isn't really a well-defined term anyway.
Why does this matter to you? Well, you have a bunch of Python source code that you want to use with the .NET framework. If that code doesn't use any of the CPython-specific features -- such as using C extension modules -- then you can just run it in IronPython. | 0 | 1,191 | true | 0 | 1 | C# .NET interoperabillity with managed Python (CPython) -> any problems? | 10,210,229 |
2 | 2 | 1 | 1 | 3 | 1 | 0.099668 | 0 | I am working on a design of an application. The Core should be written in C# but i also want to use some already finished CPython modules (un-managed).
So I am interested in the interoperability (Call CPython method from C# and Call C# from CPython). And if there are problems, because C# runs within the .NET runtime (managed) and CPython directly un-managed.
I already investigated this issue with Google and came out to these solutions:
Use IronPython via DLR + "CPython extension" + maybe "IronClad" and call from IronPython the CPython modules and vice versa -> are these modules executed managed or unmanaged ? Are There any problems if i want to use C# classes and methods from CPython ?
Use "Python for .NET" -> the same question as above.
What do you think, which way would be better ? or do you have another solution ?
And the last but maybe most important question, did I understand the above mentioned points right, or do I mess up ?
Many thanks in advance !! | 0 | c#,.net,python,interop,ironpython | 2012-04-18T12:02:00.000 | 0 | 10,208,960 | Expose your Python code via COM and call that from C#. Used this avenue (both ways) many times. | 0 | 1,191 | false | 0 | 1 | C# .NET interoperabillity with managed Python (CPython) -> any problems? | 14,318,714 |
1 | 6 | 0 | 1 | 7 | 0 | 0.033321 | 1 | I am doing some R&D on selenium+python. I wrote some test cases in python using selenium webdriver and unittest module. I want to know how can I create report of the test cases. Is there inbuilt solution available in selenium or I need to code to generate file.
Or is there any other web testing framework with javascript support available in python which have reporting functionality.
I am basically new to python as well as selenium. Just trying to explore. | 0 | python,selenium | 2012-04-18T21:59:00.000 | 0 | 10,218,679 | My experience has been that any sufficiently useful test framework will end up needing a customized logging solution. You are going to end up wanting domain specific and context relevant information, and the pre-baked solutions never really fit the bill by virtue of being specifically designed to be generic and broadly applicable. If you are already using Python, I'd suggest looking in to the logging module and learning how to write Handlers and Formatters. It's actually pretty straight forward, and you will end up getting better results than trying to shoehorn the logging you need in to some selenium-centric module. | 0 | 24,481 | false | 1 | 1 | Selenium+python Reporting | 10,218,792 |
1 | 4 | 0 | 0 | 0 | 0 | 0 | 0 | 'lo,
I am currently trying to code a simple routine for an experiment we are planning to run. The experiment starts by entering a subject number and creating a bunch of files. I got that part working. Next, we want the screen to go blank and display a message. Something like 'Please fill in questionnaire 1 and press [ENTER] when you are done.'
My question is, how do you recommend I present a blank screen with a message like that that waits for a certain key to be pressed?
I have quite some programming experience but haven't worked with Python before so any hints are greatly appreciated. Thanks a lot in advance for your time!
~~~~~~~~~~~~~~~~~~
Some extra info that might be relevant: We are running this on Windows XP (Service Pack 2) computers. The whole point of this is that the participant does not have access to the desktop or anything on the computer basically. We want the experiment to start and display a bunch of instructions on the screen that the subject has to follow without them being able to abort etc. Hope this makes sense. | 0 | python,windows | 2012-04-19T02:41:00.000 | 0 | 10,220,943 | raw_input('Please fill in questionnaire 1 and press [ENTER] when you are done.') will wait for someone to hit [enter].
Clearing the screen may be OS/environment dependent, I am not sure. | 0 | 5,401 | false | 0 | 1 | Present blank screen, wait for key press -- how? | 10,220,978 |
1 | 2 | 0 | 4 | 3 | 0 | 0.379949 | 0 | I am considering of prototyping a web based point-of-sale system.
I don't have programming skills but I'm thinking of using this project in order to learn.
I would like to ask you the following two questions:
Do you think the above task is achievable within the period of 6 months (for building a rough prototype of the basic functions of a POS)?
If yes, which programming language would you recommend me and why? (I was thinking of Python)
Your advice is greatly appreciated! | 0 | python,point-of-sale,prototyping | 2012-04-19T20:35:00.000 | 0 | 10,236,321 | Python is a very quick and productive language to develop in, so that would be a good choice, IMO. Personally I find it the most pleasant language to develop in.
But I think a POS system is a terrible first programming project. A proper POS system covers too many aspects like security, authentication, data storage, client-server. Each of those has its own gotcha's and significant learning curve.
If you want to go through with it nonetheless, chop the project up into manageable pieces that can be built and tested separately. You could start by writing a simple program that accepts text commands from the console and stores the transactions in e.g. a text file or in a pickled Python dictionary. This would be the start of the server. Later you can add a web or GUI front-end, or have the server store transactions in a database. | 0 | 9,646 | false | 1 | 1 | Creating a web based point of sale system | 10,236,867 |
2 | 6 | 0 | 0 | 116 | 1 | 0 | 0 | We are using Pylint within our build system.
We have a Python package within our code base that has throwaway code, and I'd like to disable all warnings for a module temporarily so I can stop bugging the other devs with these superfluous messages. Is there an easy way to pylint: disable all warnings for a module? | 0 | python,pylint | 2012-04-19T23:53:00.000 | 0 | 10,238,473 | My use case is to run pylint *.py to process all files in a directory, except that I want to skip one particular file.
Adding # pylint: skip-file caused Pylint to fail with I: 8, 0: Ignoring entire file (file-ignored). Adding # pylint: disable=file-ignored does not fix that. Presumably, it's a global error rather than a file-specific one.
The solution was to include --disable=file-ignored in the Pylint command options. It took way too long to figure this out; there shouldn't be a file-ignored error when you explicitly ignore a file. | 0 | 88,564 | false | 0 | 1 | Disable all Pylint warnings for a file | 44,339,590 |
2 | 6 | 0 | 7 | 116 | 1 | 1 | 0 | We are using Pylint within our build system.
We have a Python package within our code base that has throwaway code, and I'd like to disable all warnings for a module temporarily so I can stop bugging the other devs with these superfluous messages. Is there an easy way to pylint: disable all warnings for a module? | 0 | python,pylint | 2012-04-19T23:53:00.000 | 0 | 10,238,473 | Another option is to use the --ignore command line option to skip analysis for some files. | 0 | 88,564 | false | 0 | 1 | Disable all Pylint warnings for a file | 10,276,255 |
1 | 1 | 0 | 1 | 2 | 1 | 1.2 | 0 | I am trying to handle the different encodings in a Python script the more user-friendly and auto-magic way possible (there are APIs for utf8). It is a cross-platform console script.
For printing to stdout I use sys.stdout.encoding and it seems to do the right thing almost always when printing to the console. However when stdout is piped it becomes None.
So in that case I assume I am piping to a file and use locale.getpreferredencoding() but:
I am not sure this is the right encoding for printing to a file, but it works quite cross-platform.
That doesn't work when piping to a program |. I don't know how to detect that this is the case neither if there is a standard or an expected behavior for encoding in that case. | 0 | python,character-encoding | 2012-04-20T15:38:00.000 | 0 | 10,249,240 | If it is None, simply output your data as utf-8, and document it. If it happens that there are use cases for other encodings, make that an option through the command line or other means. | 0 | 643 | true | 0 | 1 | What should I do when sys.stdout.encoding is None? | 10,250,521 |
1 | 2 | 0 | 3 | 0 | 0 | 1.2 | 1 | I'm new to cgi and python, so I've been making quite a few mistakes. The problem is that if something goes wrong with the script, I just get a 500 error on the webpage. The only way I can see what caused the error is by executing the page via ssh, but the page involves file uploads, so I can't test that part.
Is there a way I can output Python errors to a file? | 0 | python,cgi | 2012-04-20T21:37:00.000 | 0 | 10,253,898 | there are a couple of options, use the logging module as directed, you can tail the server's error log, and you can enable cgitb with import cgitb; cgitb.enable()
Depending on exactly where the error occurs, the error will show up in different places, so checking all three, and using print statements and exception blocks helps to debug your code.
With file uploads, I've found I have to explicitly state enctype="multipart/form-data" in the form tag or it breaks, often quietly. | 0 | 2,081 | true | 0 | 1 | Logging python errors on website? | 10,254,010 |
1 | 5 | 0 | 7 | 2 | 0 | 1 | 0 | I need to script my app (not a game) and I have a problem, choosing a script lang for this.
Lua looks fine (actually, it is ideal for my task), but it has problems with unicode strings, which will be used.
Also, I thought about Python, but I don't like It's syntax, and it's Dll is too big for me ( about 2.5 Mib).
Python and other such langs have too much functions, battaries and modules which i do not need (e.g. I/O functions) - script just need to implement logic, all other will do my app.
So, I'd like to know is there a scripting lang, which satisfies this conditions:
unicode strings
I can import C++ functions and then call them from
script
Can be embedded to app (no dll's) without any problems
Reinventing the wheel is not a good idea, so I don't want to develop my own lang.
Or there is a way to write unicode strings in Lua's source? Like in C++ L"Unicode string" | 0 | python,scripting,programming-languages,lua | 2012-04-21T19:10:00.000 | 1 | 10,262,114 | Lua strings are encoding-agnostic. So, yes, you can write unicode strings in Lua scripts. If you need pattern matching, then the standard Lua string library does not support unicode classes. But plain substring search works. | 0 | 492 | false | 0 | 1 | Choosing Scripting lang | 10,262,395 |
2 | 2 | 0 | 0 | 0 | 1 | 0 | 0 | I need the python moduel py4cs, but I cannot find it anywhere, it is not on pypi or anywhere else. Please Help. Thanks! | 0 | python | 2012-04-22T04:56:00.000 | 0 | 10,265,351 | It comes with the book "Python Scripting for Computational Science". | 0 | 186 | false | 0 | 1 | Where to find a python module, py4cs? | 10,265,367 |
2 | 2 | 0 | 1 | 0 | 1 | 0.099668 | 0 | I need the python moduel py4cs, but I cannot find it anywhere, it is not on pypi or anywhere else. Please Help. Thanks! | 0 | python | 2012-04-22T04:56:00.000 | 0 | 10,265,351 | It is a set of tools useful for scientific programming in Python. Initially, it was distributed as py4cs only with purchase of the book by Hans Petter Langtangen. It is now called scitools and is widely available. | 0 | 186 | false | 0 | 1 | Where to find a python module, py4cs? | 23,199,828 |
1 | 1 | 0 | 0 | 0 | 1 | 1.2 | 0 | When I was reading examples for testing a package in multiple pythons with tox I found about a command "build_tests" that would put (2to3'd) test files in build/ directory. I could also google it in some projects' tox.ini files and some gentoo ebuilds, but I still don't know which package installs this command. I have python 3.2, last nosetests and last distribute, but "python setup.py build_tests" still gives error.
So what do I have to install to get this command? | 0 | python,unit-testing,nose,distribute,python-2to3 | 2012-04-22T13:09:00.000 | 0 | 10,268,189 | OK, I did some more lookup and I found that at least in nose there is a custom script that adds this command. So I will probably have to copy this idea if I want to have tests for py3k. | 0 | 82 | true | 0 | 1 | Where to find build_tests command? | 10,294,908 |
1 | 3 | 0 | 4 | 0 | 1 | 0.26052 | 0 | I am attempting to write a script that will pull out NTLM hashes from a text file that contains about 500,000 lines of data. Not all accounts contain hashes and I only need the ones that do contain hashes.
Here is a sample of what the data looks like:
Mango Chango A (a):$NT$547e2494658ca345d3847c36cf1fsef8:::
There are thousands of other lines in the file, but that particular line is what I need taken out of the file. There are about 100 lines that apply to that and I do not want to manually go through the entire file searching for that.
Is there an easy script or something I can run in Linux to pull lines that follow that pattern out of the file?
Thank you! | 0 | python,perl,bash,sed,awk | 2012-04-23T14:05:00.000 | 0 | 10,282,132 | grep '\$NT\$'filename
If there might be other occurrences of $NT$ outside the field you're looking for, you could be more specific - this will find only lines that have it in the second colon-delimited field:
awk -F: '$2 ~ /\$NT\$/'filename | 0 | 575 | false | 0 | 1 | Script to pull hashes out of large text file | 10,282,359 |
1 | 3 | 0 | 0 | 0 | 1 | 0 | 0 | I am creating a module in python that can take multiple arguments. What would be the best way to pass the arguments to the definition of a method?
def abc(arg):
...
abc({"host" : "10.1.0.100", "protocol" : "http"})
def abc(host, protocol):
...
abc("10.1.0.100", "http")
def abc(**kwargs):
...
abc(host = "10.1.0.100", protocol = "http")
Or something else?
Edit
I will actually have those arguments (username, password, protocol, host, password2) where none of them are required. | 0 | python | 2012-04-23T17:59:00.000 | 0 | 10,285,748 | If all the arguments are known ahead, use an explicit argument list, optionally with default values, like def abc(arg1="hello", arg2="world",...). This will make the code most readable.
When you call the function, you can use either abd("hello", "world") or abc(arg1="hello", arg2="world"). I use the longer form if there are more than 4 or 5 arguments, it's a matter of taste. | 0 | 1,331 | false | 0 | 1 | What is the best way to pass multiple parameters to class init in python? | 10,285,800 |
1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | I'd like to develop an app that runs natively (self-contained executable) for both Mac and Windows that will detect/poll for a USB device being inserted and send an HTTP call as a result. I'm mainly a Ruby programmer, so ideally I could do this with a combination of Macruby/IronRuby and shared libraries, but it's looking like libusb requires a special driver to be installed on Windows (which I can't expect the clients to do).
Are there libraries/gems that would facilitate this? Is it possible to do what I'm describing using Python/Ruby? It's not as important to be shared code as it is that the codebase is Python/Ruby/single language. libusb would be ideal if it didn't require an install of a special driver on Windows. | 0 | python,ruby,usb,native | 2012-04-23T20:34:00.000 | 1 | 10,287,853 | Well it is definitely possible; I don't know what the equivalent is in rubygems by pyUSB is a easy to use module you can leverage to do this and then there are numerous http libraries for python.
As for making it self contained, it is possible but not ideal. py2exe is a program that basically takes a copy of the python interpreter, all dependencies used in your programs and your script and glues it all together in a exe file, but by default py2exe will not pack it into a exe, but there are instructions on the wiki | 0 | 528 | false | 0 | 1 | Cross-platform USB development for Mac/Windows - possible with Ruby/Python? | 10,289,020 |
1 | 1 | 0 | 0 | 3 | 1 | 0 | 0 | I have a software that uses multiple languages, which are all available as eclipse plugins (java, c++, python). The exes call each other. I was wondering if there is a way I could debug all these languages using eclipse. I have the sources for all of them, and all of them are projects in eclipse, but so far they work independently, and I was wondering whether, for example, if I added a break point in a C++ code and called a java program that calls the C++ code, the execution would pause when it reaches the C++ breakpoint. I think this is somehow similar to 'attaching to a process' in Visual Studio, though I'm not sure whether Visual Studio provides this feature either. Is it possible with eclipse or Visual Studio ? | 0 | java,c++,python,eclipse,visual-studio | 2012-04-23T21:18:00.000 | 0 | 10,288,488 | To my knowledge, Eclipse has no support for multidebugger debugging. However, it might be possible to debug the same workspace in many Eclipse instance at the same time. Simply launch the debugger for each language separately by attaching to them as you said. | 0 | 240 | false | 0 | 1 | multi language IDE | 10,288,556 |
1 | 4 | 0 | 0 | 0 | 1 | 0 | 0 | I got txt file A with 300, 000+ lines and txt file B with 600, 000+ lines. Now what I want to do is to sift through file A line by line, if that line does not appear in file B then it will be appended to file C.
Well, the problem is if I program like what I said above, it literally takes ages to finish all the job. So is there a better way to do this? | 0 | python,compare | 2012-04-24T16:04:00.000 | 0 | 10,301,687 | Don't know anything about python, but: how about sorting the file A into a particular order? Then you can go through file B line by line and do a binary search - more efficient. | 0 | 477 | false | 0 | 1 | What's the fastest way to find unique lines from huge file A as compared to huge file B using python? | 10,301,739 |
1 | 2 | 0 | 0 | 1 | 1 | 0 | 0 | I'm currently using json and http to call perl functions from python, but it's slow. Based on some research, messagepack is best for serialization and zeromq is the best transport. Both have cross platform bindings, but before I dig in, I would like to know what others are using for fast cross-language RPC (preferably with persistent tcp connections) | 0 | python,perl,rpc,zeromq,msgpack | 2012-04-25T05:00:00.000 | 0 | 10,309,579 | After studying this for a couple days I'm going with ZeroMQ + messagepack. The ZeroMQ docs show how to use messagepack, and I can implement an RPC server or client in only a few lines. The ZeroMQ modules for perl and python both have JSON serialization built in, so it's possible to implement RPC with ZeroMQ alone, but messagepack will give a nice boost to my data heavy calls. Thrift looks nice too, but it adds an extra configuration file and is fairly high level. I am sure to get max performance with ZeroMQ and it leaves a lot more options open. | 0 | 523 | false | 0 | 1 | RPC between python and perl | 10,339,941 |
1 | 1 | 0 | 0 | 2 | 0 | 1.2 | 0 | I'm working in a multiuser environment with the following setup:
Linux 64bits environment (users can login in to different servers).
Eclipse (IBM Eclipse RSA-RTE) 32bits. So Java VM, Eclipse and PyDev is 32bits.
Python 3 interpreter is only available for 64bits at this moment.
In the preferences for PyDev, I want to set the path to the Python interpreter like this:
/app/python/@sys/3.2.2/bin/python
In Eclipse/PyDev, @sys points to i386_linux26 even if the system actually is amd64_linux26. So if I do not explicitly write amd64_linux26 instead of @sys, PyDev will not be able to find the Python 3 interpreter which is only available for 64bits. The link works as expected outside Eclipse/PyDev, e.g. in the terminal.
Any ideas how to force Eclipse/PyDev to use the real value of @sys?
Thanks in advance! | 0 | python,linux,eclipse,pydev | 2012-04-25T12:05:00.000 | 1 | 10,315,232 | I don't really think there's anything that can be done on the PyDev side... it seems @sys is resolved based on the kind of process you're running (not your system), so, if you use a 64 bit vm (I think) it should work...
Other than that, you may have to provide the actual path instead of using @sys... | 0 | 321 | true | 1 | 1 | Eclipse / PyDev overrides @sys, cannot find Python 64bits interpreter | 10,343,117 |
1 | 3 | 0 | 4 | 12 | 0 | 0.26052 | 0 | Firstly, I should state that my current development environment is MSYS + mingw-w64 + ActivePython under Windows 7 and that on a normal day I am primarily a Linux developer. I am having no joy obtaining, or compiling, a version of the Python library with debug symbols.
I need both 32bit and 64bit debug versions of the Python27.dll file, ideally. I want to be able to embed Python and implement Python extensions in C++, and be able to call upon a seamless debugging facility using the gdb-7.4 I have built for mingw-w64, and WingIDE for the pure Python side of things.
Building Python 2.7.3 from source with my mingw-w64 toolchain is proving too problematic -- and before anyone flames me for trying: I acknowledge that this environment is unsupported, but I thought I might be able to get this working with a few judicious patches (hacks) and:
make OPT='-g -DMS_WIN32 -DWIN32 -DNDEBUG -D_WINDOWS -DUSE_DL_EXPORT'
I was wrong... I gave up at posixmodule.c since the impact of my changes became uncertain; ymmv.
I have tried building with Visual C++ 2010 Express but being primarily a Linux developer the culture-shock is too much for me to bear today; the Python project does not even import successfully. Apparently, I need Visual C++ 2008, yet I am already convinced I don't want to go down this road if at all possible...
It's really surprising to me that there is not a zip-file providing the requisite .dlls somewhere on the Internet. ActiveState should really provide these as an optional download with each release of ActivePython that they make -- perhaps that's where the paid support comes in ;-).
What is the best way to obtain the Python debug library files given my environment? | 0 | python,gdb,debug-symbols,activepython,mingw-w64 | 2012-04-25T12:31:00.000 | 1 | 10,315,662 | The best way to create a debug version of Python under Windows is to use the Debug build in the Visual Studio projects that come with the Python source, using the compiler version needed for the specific Python release, i.e. VS 2008.
There may be other ways, but this is certainly the best way.
If you really need a 64-bit debug build also, the best way is to buy a copy of VS 2008 (i.e. not use the Express version). It may be possible to create an AMD64 debug build using the SDK 64-bit compiler, but again, using the officially-supported procedures is the best way. | 0 | 12,543 | false | 0 | 1 | How to obtain pre-built *debug* version of Python library (e.g. Python27_d.dll) for Windows | 10,323,635 |
2 | 2 | 0 | 1 | 0 | 0 | 1.2 | 0 | I am building an application, which has an application based front-end in C++/Qt and a web based front-end in Python (using Django) framework. I'm trying to migrate the architecture to services-based, as both these front-ends have business logic embedded in them, which makes it hard to maintain.
I'm thinking of choosing Thrift to write the RPC services, which can be consumed by the other modules in the system and Python code. However, as it seems, Thrift does not work well with Windows, so I'm left with the option of converting the Thrift output to some C++ structures, which theen need to be serialized/de-serialized again, so that the services can be consumed by Qt/C++. Python code can consume these Thrift services easily.
In this process, I need to convert/serialize the structure, first according to the Thrift IDL and then some custom code. Any suggestions to change the architecture, so as to
keep it simple
works with multiple languages
quick to implement? | 0 | c++,python,architecture,thrift | 2012-04-25T14:18:00.000 | 0 | 10,317,632 | you could consider:
already mentioned CORBA solution: built in marshaling, compact binary protocol
REST http and based json server: simple, a bit chatty on the network, you need to serialize your data to json
AMQP messaging + json or some other serializer: you need to serialize your data to json or something else like google protocol buffers, plus is that scaling if you need more servers will be simpler. | 0 | 254 | true | 1 | 1 | migrating business logic to services: alternatives to Thrift | 10,328,853 |
2 | 2 | 0 | 1 | 0 | 0 | 0.099668 | 0 | I am building an application, which has an application based front-end in C++/Qt and a web based front-end in Python (using Django) framework. I'm trying to migrate the architecture to services-based, as both these front-ends have business logic embedded in them, which makes it hard to maintain.
I'm thinking of choosing Thrift to write the RPC services, which can be consumed by the other modules in the system and Python code. However, as it seems, Thrift does not work well with Windows, so I'm left with the option of converting the Thrift output to some C++ structures, which theen need to be serialized/de-serialized again, so that the services can be consumed by Qt/C++. Python code can consume these Thrift services easily.
In this process, I need to convert/serialize the structure, first according to the Thrift IDL and then some custom code. Any suggestions to change the architecture, so as to
keep it simple
works with multiple languages
quick to implement? | 0 | c++,python,architecture,thrift | 2012-04-25T14:18:00.000 | 0 | 10,317,632 | I've implemented something similar using omniORB. It has bindings for python and for C++. It's really easy in python and performs very well. | 0 | 254 | false | 1 | 1 | migrating business logic to services: alternatives to Thrift | 10,317,981 |
1 | 2 | 0 | 1 | 6 | 0 | 0.099668 | 0 | Is python supported on Giraph and if it is, is it as well-supported as python is on Hadoop or well it lead to considerably worse performance than using raw Java? | 0 | python,graph,hadoop,graph-theory | 2012-04-25T23:09:00.000 | 0 | 10,325,072 | Streaming out to a scripting language is not yet supported but certainly would be a good addition. Patches welcome. | 0 | 2,017 | false | 0 | 1 | Can I use python with giraph? | 11,112,245 |
1 | 2 | 0 | 1 | 0 | 0 | 0.099668 | 0 | I'm assuming with a call to a UNIX shell, but I was wondering if there are other options from within Python. | 0 | python,macos,unix,filesystems,osx-lion | 2012-04-26T05:40:00.000 | 1 | 10,327,804 | os.link claims to work on all Unix platforms. Are there any OS X specific issues with it? | 0 | 2,229 | false | 0 | 1 | How to create a hard link from within a Python script on a Mac? | 10,327,842 |
1 | 1 | 0 | 1 | 0 | 0 | 0.197375 | 0 | After installing python on Linux, smtpd.py will be installed under /usr/bin directory. Why does this module exist here? How about the other one under directory /usr/lib/python2.x? What's the difference? | 0 | python | 2012-04-26T14:12:00.000 | 1 | 10,335,259 | The one in /usr/bin is in your PATH and can be executed by calling its filename in a shell.
The second one is in library directory referenced by PYTHONPATH or sys.path and can be used as a module in python scripts.
They are probably hard or symlinks if they have the same content. | 0 | 181 | false | 0 | 1 | Why two smtpd.py are installed? | 10,335,348 |
3 | 7 | 0 | 6 | 10 | 0 | 1.2 | 0 | I am running a process on a S7-1200 plc and I need it to send a start signal to my python script, after the script is done running it needs to send something back to the plc to initiate the next phase. Oh, and it has to be done in ladder.
Is there a quick and dirty way to send things over profibus or am I better off using just a RS232 thing? | 0 | python,plc,siemens,s7-1200 | 2012-04-27T18:30:00.000 | 0 | 10,355,953 | After failing with libnodave and OPC, I created a TCON,TSEND and TRECV communication thing. It transmits a byte over TCP and it works. | 0 | 38,421 | true | 1 | 1 | How can I communicate between a Siemens S7-1200 and python? | 10,782,983 |
3 | 7 | 0 | 2 | 10 | 0 | 0.057081 | 0 | I am running a process on a S7-1200 plc and I need it to send a start signal to my python script, after the script is done running it needs to send something back to the plc to initiate the next phase. Oh, and it has to be done in ladder.
Is there a quick and dirty way to send things over profibus or am I better off using just a RS232 thing? | 0 | python,plc,siemens,s7-1200 | 2012-04-27T18:30:00.000 | 0 | 10,355,953 | There is a commercial library called "S7connector" by Rothenbacher GmbH (obviously it's not the "s7connector" on sourceforge).
It is for the .NET framework, so could be used with IronPython.
It does work with S7-1200 PLCs. You just have to make sure a DB you want to read from / write to is not an optimized S7-1200 style DB, but a S7-300/400 compatible one, an option which you can set when creating a DB in TIA portal.
This lib also allows to read and write all I/O ports - the "shadow registers" (not sure what they're called officially) and directly as well, overriding the former. | 0 | 38,421 | false | 1 | 1 | How can I communicate between a Siemens S7-1200 and python? | 24,056,273 |
3 | 7 | 0 | 1 | 10 | 0 | 0.028564 | 0 | I am running a process on a S7-1200 plc and I need it to send a start signal to my python script, after the script is done running it needs to send something back to the plc to initiate the next phase. Oh, and it has to be done in ladder.
Is there a quick and dirty way to send things over profibus or am I better off using just a RS232 thing? | 0 | python,plc,siemens,s7-1200 | 2012-04-27T18:30:00.000 | 0 | 10,355,953 | Ther best way to communicate with S7-1200 PLC cpu's is with OPC UA or Classic OPC (ommonly known as OPC DA. ) Libnodave is made for S7-300 and S7-400 not for S71200 (2.x firmware).
If you use a third party solution to communicate with S7-1200 (or S7-1500) you have to decrease the security level at the PLC by allowing the put and get mechanism. Put and get are pure evil to use. You open the memory of the CPU for every process. Don’t use them anymore. Siemens should actually block this.
This applies for all firmware release for S7-1200.
Siemens pushes people you use OPC UA as default communication from PLC. What makes sense, because OPC UA is the protocol for industry 4.0 and IIoT.
Edit: rewrite everything. Info was heavily outdated.
If you use a firmware 2 or 3 1200, consider replacement or upgrade. These versions are no longer supported and contains the worm issue. | 0 | 38,421 | false | 1 | 1 | How can I communicate between a Siemens S7-1200 and python? | 10,773,413 |
1 | 2 | 0 | 2 | 5 | 0 | 1.2 | 0 | I new to Python and to programming in general. I'm a novice, and do not work in programming, just trying to teach myself how to program as a hobby. Prior to Python, I worked with Ruby for a bit and I learned that one of the biggest challenges was actually properly setting up my computer.
Background: I'm on a Macbook with OSX 10.7.
With Ruby, you have to (or rather, you should), edit your ./profile and add PATH info. When you install and use RVM, there are additional items you need to add to your bash_profile.
Do you have to make similar changes with Python? What are the best practices as I'm installing/getting started to ensure I can install modules and packages correctly? | 0 | python,profile,.bash-profile | 2012-04-28T23:08:00.000 | 1 | 10,368,361 | python works out of the box on OS X (as does ruby, for that matter). The only changes I would recommend for a beginner are:
1) Python likes to be reassured that the terminal can handle UTF-8 before it will print Unicode strings. Add export LANG=en_US.UTF-8 to .profile. (It may be that the .UTF-8 part is already present by default on Lion - I haven't checked since Snow Leopard.) Of course, this is something that will help you in debugging, but you shouldn't rely on it being set this way on other machines.
2) Install pip by doing easy_install pip (add sudo if necessary). After that, install Python packages using pip install; this way, you can easily remove them using pip uninstall. | 0 | 479 | true | 0 | 1 | Proper Unix (.profile, .bash_profile) changes for Python usage | 10,368,402 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.