Search Results

Search found 15187 results on 608 pages for 'boost python'.

Page 48/608 | < Previous Page | 44 45 46 47 48 49 50 51 52 53 54 55  | Next Page >

  • How can I process command line arguments in Python?

    - by photographer
    What would be an easy expression to process command line arguments if I'm expecting anything like 001 or 999 (let's limit expectations to 001...999 range for this time), and few other arguments passed, and would like to ignore any unexpected? I understand if for example I need to find out if "debug" was passed among parameters it'll be something like that: if 'debug' in argv[1:]: print 'Will be running in debug mode.' How to find out if 009 or 575 was passed? All those are expected calls: python script.py python script.py 011 python script.py 256 debug python script.py 391 xls python script.py 999 debug pdf At this point I don't care about calls like that: python script.py 001 002 245 568 python script.py some unexpected argument python script.py 0001 python script.py 02 ...first one - because of more than one "numeric" argument; second - because of... well, unexpected arguments; third and fourth - because of non-3-digits arguments.

    Read the article

  • Python installation error (1fc8b3b9a1e18e3b)

    - by jags
    I am trying to install Python but I'm running into following error: An Error occurred during the installation of assembly Microsoft.VC90.CRT, version="9.0.21022.8" publicKeyToken="1fc8b3b9a1e18e3b", processorArchitecture="x86", type="win32" I am using Windows 7 Professional Service Pack 1, 32 bit OS with i7 Processor. I have searched on the internet regarding this error but couldn't find any solution specific to my problem.

    Read the article

  • Executing Windows administrative shell commands on Windows using Python

    - by at0m
    I have a batch script using Windows shell commands to perform several administrative actions. The script is running great on Windows 7 but when i try launching it from Python 2.6 nothing happens: import os a = os.popen("somebatchfile.bat") I assume that this is because the bat file uses several commands that require an administrative privileges but i don't want to prompt to a password using runas.exe or embedding the password within the code. Is there any way to make UAC prompt for user approval or something?

    Read the article

  • Accessing vSphere ESX/ESXi server through python

    - by William
    Hi, I'd like to automatically obtain a list or array of the VMs (mac address/name/resource pool) currently created on a vSphere server and use it in a python app. Can someone please suggest a good approach or solution to do this? I'm rather new to the vSphere platform. Thanks.

    Read the article

  • Accessing MySQL server via VPN in python

    - by user210481
    Hi I have a MySQL server that I need access through a VPN. I use MySQLdb package to access MySQL server in Python. When I can access the server without VPN, it works fine, but when I'm at certain locations, I need to connect through VPN. My computer is connected to the VPN and I can access the database through PHPMyAdmin, but MySQLdb gives me an error message: OperationalError: (2003, "Can't connect to MySQL server on 'MY_IP' (10061)") Any ideas on why it's not working? Thanks

    Read the article

  • CentOS5 python wrong ELF class: ELFCLASS32

    - by user788171
    Has anybody ever encountered this wrong ELF class error? The failure is provided in more detail below: [root@nocloud ~]# system-config-users Traceback (most recent call last): File "/usr/share/system-config-users/system-config-users.py", line 25, in ? import libuser ImportError: /usr/lib/python2.4/site-packages/libusermodule.so: wrong ELF class: ELFCLASS32 Can anybody tell me how I might possibly be able to fix this? It looks like python broke on my server.

    Read the article

  • Python to see if a file falls into a date range

    - by tod
    I have a script that I want to have an if statement check if a file falls between several specified date periods as it searches directories. I have been able to get the time in %Y-%m-%d format for the file, but I can't seem to be able to specify a date range for python to go through. Any ideas/help? Here's what I have so far for name in files: f = os.path.join(root, name) dt = os.path.getmtime(f) nwdt = time.gmtime(dt) ndt = time.strftime('%Y-%m-%d', nwdt)

    Read the article

  • Installing mysql-server with python ssh connection

    - by mrbox
    I'm writing a script in Python, which is connecting to server via ssh, then installing some packages. But there is problem with dialogue box, where i can type in a root password- i don't know how to send data there. Once I tried to do this, my apt(using Debian Lenny) gone crazy. Here is some info: - Debian Lenny - Using PySSH with easier interface, code looks like this: clientSSH = SSHClient( self.ip, 'root', self.rootPassword, None ) clientSSH.login() clientSSH.run_command('apt-get install mysql-server mysql-client php5') clientSSH.run_command('Y') #I Don't know how send root passwd here clientSSH.logout()

    Read the article

  • Updating Python on Ubuntu system

    - by efficiencyIsBliss
    I want to update the Python build on my Linux box, but the only way I know how to do it is uninstalling the current version and installing the new one. My system is already up to date (I updated yesterday). I wanted to know if there is a way to update a specific program from the command line, like sudo apt-get update <program-name>. I know this command doesn't exist, but I'm hoping something equivalent does.

    Read the article

  • Copy vector of values to vector of pairs in one line

    - by Kirill V. Lyadvinsky
    I have the following types: struct X { int x; X( int val ) : x(val) {} }; struct X2 { int x2; X2() : x2() {} }; typedef std::pair<X, X2> pair_t; typedef std::vector<pair_t> pairs_vec_t; typedef std::vector<X> X_vec_t; I need to initialize instance of pairs_vec_t with values from X_vec_t. I use the following code and it works as expected: int main() { pairs_vec_t ps; X_vec_t xs; // this is not empty in the production code ps.reserve( xs.size() ); { // I want to change this block to one line code. struct get_pair { pair_t operator()( const X& value ) { return std::make_pair( value, X2() ); } }; std::transform( xs.begin(), xs.end(), back_inserter(ps), get_pair() ); } return 0; } What I'm trying to do is to reduce my copying block to one line with using boost::bind. This code is not working: for_each( xs.begin(), xs.end(), boost::bind( &pairs_vec_t::push_back, ps, boost::bind( &std::make_pair, _1, X2() ) ) ); I know why it is not working, but I want to know how to make it working without declaring extra functions and structs?

    Read the article

  • How do I configure multiple Ubuntu Python installations to avoid App Engine's SSL error?

    - by Linc
    I have Karmic Koala which has Python 2.6 installed by default. However I can't run any Python App Engine projects because they require Python 2.5 and python ssl. To install ssl I installed python2.5-dev first while following some instructions I found elsewhere. sudo apt-get install libssl-dev sudo apt-get install python-setuptools sudo apt-get install python2.5-dev sudo easy_install-2.5 pyopenssl However, I am afraid this is not good for my Ubuntu installation since Ubuntu expects to see version 2.6 of Python when you type 'python' on the command line. Instead, it says '2.5.5'. I tried to revert to the original default version of Python by doing this: sudo apt-get remove python2.5-dev But that didn't seem to do anything either - when I type 'python' on the command line it still say 2.5.5. And App Engine still doesn't work after all this. I continue to get an SSL-related error whenever I try to run my Python app: AttributeError: 'module' object has no attribute 'HTTPSHandler' UPDATE: Just checked whether SSL actually installed as a result of those commands by typing this: $ python2.5 Python 2.5.5 (r255:77872, Apr 29 2010, 23:59:20) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import ssl Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named ssl >>> As you can see, SSL is still not installed, which explains the continuing App Engine error. If anyone knows how I can dig myself out of this hole, I would appreciate it.

    Read the article

  • python2.7 help() modules returnd error

    - by GerberaH
    # python Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> help() Welcome to Python 2.7! This is the online help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://docs.python.org/tutorial/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam". help> modules Please wait a moment while I gather a list of all available modules... /usr/lib/python2.7/dist-packages/gobject/constants.py:24: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed import gobject._gobject /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_boxed_type_register_static: assertion `g_type_from_name (name) == 0' failed from gtk import _gtk ** (python:6240): CRITICAL **: pyg_register_boxed: assertion `boxed_type != 0' failed /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register existing type `GdkDevice' from gtk import _gtk /usr/lib/python2.7/dist-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_get_qdata: assertion `node != NULL' failed from gtk import _gtk Speicherzugriffsfehler (Speicherabzug geschrieben)

    Read the article

  • Secure method of changing a user's password via Python script/non-interactively

    - by Matthew Rankin
    I've created a Python script using Fabric to configure a freshly built Slicehost Ubuntu slice. In case you're not familiar with Fabric, it uses Paramiko, a Python SSH2 client, to provide remote access "for application deployment or systems administration tasks." One of the first things I have the Fabric script do is to create a new admin user and set their password. Unlike Pexpect, Fabric cannot handle interactive commands on the remote system, so I need to set the user's password non-interactively. At present, I'm using the chpasswd command to change the password. This transmits the password as clear text over SSH to the remote system. Questions Is my current method of setting the password a security concern? Currently, the drawback I see is that Fabric shows the password as clear text on my local system as follows: [xxx.xx.xx.xxx] run: echo "johnsmith:supersecretpassw0rd" | chpasswd. Since I only run the Fabric script from my laptop, I don't think this is a security issue, but I'm interested in others' input. Is there a better method for setting the user's password non-interactively? Another option, would be to use Pexpect from within the Fabric script to set the password. Current Code # Fabric imports and host configuration excluded for brevity root_password = getpass.getpass("Root's password given by SliceManager: ") admin_username = prompt("Enter a username for the admin user to create: ") admin_password = getpass.getpass("Enter a password for the admin user: ") env.user = 'root' env.password = root_password # Create the admin group and add it to the sudoers file admin_group = 'admin' run('addgroup {group}'.format(group=admin_group)) run('echo "%{group} ALL=(ALL) ALL" >> /etc/sudoers'.format( group=admin_group) ) # Create the new admin user (default group=username); add to admin group run('adduser {username} --disabled-password --gecos ""'.format( username=admin_username) ) run('adduser {username} {group}'.format( username=admin_username, group=admin_group) ) # Set the password for the new admin user run('echo "{username}:{password}" | chpasswd'.format( username=admin_username, password=admin_password) ) Local System Terminal I/O $ fab config_rebuilt_slice Root's password given by SliceManager: Enter a username for the admin user to create: johnsmith Enter a password for the admin user: [xxx.xx.xx.xxx] run: addgroup admin [xxx.xx.xx.xxx] out: Adding group `admin' (GID 1000) ... [xxx.xx.xx.xxx] out: Done. [xxx.xx.xx.xxx] run: echo "%admin ALL=(ALL) ALL" >> /etc/sudoers [xxx.xx.xx.xxx] run: adduser johnsmith --disabled-password --gecos "" [xxx.xx.xx.xxx] out: Adding user `johnsmith' ... [xxx.xx.xx.xxx] out: Adding new group `johnsmith' (1001) ... [xxx.xx.xx.xxx] out: Adding new user `johnsmith' (1000) with group `johnsmith' ... [xxx.xx.xx.xxx] out: Creating home directory `/home/johnsmith' ... [xxx.xx.xx.xxx] out: Copying files from `/etc/skel' ... [xxx.xx.xx.xxx] run: adduser johnsmith admin [xxx.xx.xx.xxx] out: Adding user `johnsmith' to group `admin' ... [xxx.xx.xx.xxx] out: Adding user johnsmith to group admin [xxx.xx.xx.xxx] out: Done. [xxx.xx.xx.xxx] run: echo "johnsmith:supersecretpassw0rd" | chpasswd [xxx.xx.xx.xxx] run: passwd --lock root [xxx.xx.xx.xxx] out: passwd: password expiry information changed. Done. Disconnecting from [email protected]... done.

    Read the article

  • Call functions in AutoIt DLL using Python ctypes

    - by Josh
    I want to call functions from an AutoIt dll, that I found at C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll using Python. I know I could use win32com.client.Dispatch("AutoItX3.Control") but I can't install the application or register anything in the system. So far, this is where I am: from ctypes import * path = r"C:\Program Files (x86)\AutoIt3\AutoItX\AutoItX3.dll" autoit = windll.LoadLibrary(path) Here are the methods that works: autoit.AU3_WinMinimizeAll() # windows were successfully minimized. autoit.AU3_Sleep(1000) # sleeps 1 sec. Here is my problem, python is crashing when I call other methods like this one. I get python.exe has stopped working from windows... autoit.AU3_WinGetHandle('Untitled - Notepad', '') And some other methods are not crashing python but are just not working. This one doesn't close the window and return 0: autoit.AU3_WinClose('Untitled - Notepad', '') And this other one return 1 but the window is still minimized: autoit.AU3_WinActivate('Untitled - Notepad', '') I've tested the examples with with Dispatch("AutoItX3.Control") and everything is working like expected. It seems like methods that should return something other than a string are crashing python. But still, others like WinClose are not even working... Thank you in advance for your help! EDIT: These methods are now working when using unicode strings: autoit.AU3_WinClose(u'Untitled - Notepad', u'') autoit.AU3_WinActivate(u'Untitled - Notepad', u'') And I found the prototype for AU3_WinGetHandle: AU3_API void WINAPI AU3_WinGetHandle(const char szTitle, /[in,defaultvalue("")]*/const char *szText, char *szRetText, int nBufSize); Now I see that I should get the handle from szRetText but I am not sure how... I tried the following without success: from ctypes.wintypes import LPCWSTR, INT, POINTER AU3_WinGetHandle.argtypes = (LPCWSTR, LPCWSTR, POINTER(LPCWSTR), INT) s = c_wchar_p() print AU3_WinGetHandle(u'Untitled - Notepad', u'', byref(s), 100) # prints 1 print s # prints c_wchar_p(u'') Any idea how to retrive the handle from szRetText?

    Read the article

  • Python Django MySQLdb setup problem:: setup.py dosen't build due to incorrect location of mysql

    - by 108860375137931889948
    I'm trying to install MySQLdb for python. but when I run the setup, this is the error I get. well I know why its giving all the missing file statements, but dont know where to change the bold marked location from. Please help gaurav-toshniwals-macbook-7:MySQL-python-1.2.3c1 gauravtoshniwal$ python setup.py build running build running build_py copying MySQLdb/release.py - build/lib.macosx-10.3-fat-2.6/MySQLdb running build_ext building '_mysql' extension gcc-4.0 -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=(1,2,3,'gamma',1) -D_version_=1.2.3c1 -I/Applications/MAMP/Library/include/mysql -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.3-fat-2.6/_mysql.o _mysql.c:36:23: error: my_config.h: No such file or directory _mysql.c:36:23: error: my_config.h: No such file or directory _mysql.c:38:19: error: mysql.h: No such file or directory _mysql.c:38:19:_mysql.c:39:26: error: mysqld_error.h: No such file or directory error: _mysql.c:40:20:mysql.h: No such file or directory

    Read the article

  • fastest calculation of largest prime factor of 512 bit number in python

    - by miraclesoul
    dear all, i am simulating my crypto scheme in python, i am a new user to it. p = 512 bit number and i need to calculate largest prime factor for it, i am looking for two things: Fastest code to process this large prime factorization Code that can take 512 bit of number as input and can handle it. I have seen different implementations in other languages, my whole code is in python and this is last point where i am stuck. So let me know if there is any implementation in python. Kindly explain in simple as i am new user to python sorry for bad english.

    Read the article

  • Hidden features of Python

    - by jelovirt
    What are the lesser-known but useful features of the Python programming language? Try to limit answers to Python core One feature per answer Give an example and short description of the feature, not just a link to documentation Label the feature using bold title as the first line This question is along the lines of : Hidden Features of JavaScript Hidden Features of CSS Hidden Features of C# Hidden Features of VB.Net Hidden Features of Java Hidden Features of ASP.NET Hidden Features of Python Hidden Features of TextPad Hidden Features of Eclipse Hidden Features of JavaScript

    Read the article

  • Python readability hints for a Java programmer

    - by Samuel Carrijo
    I'm a java programmer, but now entering the "realm of python" for some stuff for which Python works better. I'm quite sure a good portion of my code would look weird for a Python programmer (e.g. using parenthesis on every if). I know each language has its own conventions and set of "habits". So, from a readability standpoint what are conventions and practices which is "the way to go" in Java, but are not really the "pythonic way" to do stuff?

    Read the article

  • Python 3.1.1 Class Question

    - by Protean
    I'm a new Python programmer who is having a little trouble using 'self' in classes. For example: class data: def __init__(self): self.table = [] def add(self, file): self.table.append(file) data.add('yes') In this function I want to have table be a variable stored in the class data and use add to modify it. However, when I run this script it gives me the error: Traceback (most recent call last): File "/Projects/Python/sfdfs.py", line 7, in <module> data.add('yes') TypeError: add() takes exactly 2 positional arguments (1 given) I assume that I am trying to call the function the wrong way in this instance, as this syntax is very similar to an example in the python documentation: http://docs.python.org/3.1/tutorial/classes.html

    Read the article

  • Python: ImportError no module named urllib

    - by Yury Lifshits
    I just rented a VPS from Linode, it has python2.5 and ubuntu 8.04 When I ho to python shell python import urllib I get ImportError: No module named urllib What can be the reason? How can I add this module to python? Isn't it prepackaged with the basic version? Can it be pythonpath problem? How I can test pythonpath?

    Read the article

  • Python equivalent of IDL's stop and .reset

    - by Jamie
    Hi there, I'm relatively new to python but have a bit of experience using IDL. I was wondering if anyone knows if there are equivalent commands in python for IDL's stop and .reset commands. If I'm running some IDL script I wrote that I put a stop command in, essentially what it does is stop the script there and give me access to the command line in the middle of the script. So I have access to all the functions and variables that I defined before the stop command, which I find really useful for debugging. The .reset command I find extremely useful too. What it does is reset the the IDL environment (clears all variables, functions, etc.). It's as if I closed that session and opened a new one, but without having to exit and restart IDL. I find that if I'm trying to debug a script I wrote it's useful sometimes to start from scratch and not have to reset IDL (or python now). It would be useful also in python to be able to un-import any modules I had previously imported. Any help with these issues would be greatly appreciated. Cheers Related Python Drop into REPL Is it possible to go into ipython from code?

    Read the article

< Previous Page | 44 45 46 47 48 49 50 51 52 53 54 55  | Next Page >