Re: Strict mode?
On Dec 18, 2007 5:03 PM, Jack <[EMAIL PROTECTED]> wrote: > While enjoying the dynamic feature of Python I find it difficult to refactor > code without breaking it. For example, if I modify a function to take more > arguments, or arguments of different types, I'll need to manually find out > all places where the function is called and make sure I modify them all, > unlike in C/Java, where the compiler will do the work of checking function > signatures, etc. I suppose there isn't a strict mode in Python. It would be > helpful though, when I don't need things to be so dynamic, and this is often > the case, when it comes to function arguments and return values, for > example. Even a module level or function level flag would be very helpful to > find broken code. Or, are there any third party tools that do this? > > > -- > http://mail.python.org/mailman/listinfo/python-list > Description: A refactoring tool for python A framework and refactoring tool for Python. IDE Plugins are included for Pymacs, IDLE and Vim. Using Bicycle Repair Man you can rename classes, methods and variables, and all users of them are found and adjusted appropriately. . Homepage: http://bicyclerepair.sourceforge.net/ -- Noah Dain "The beatings will continue, until morale improves" - the Management -- http://mail.python.org/mailman/listinfo/python-list
Re: run shell commands
On Jan 10, 2008 9:24 AM, Riccardo Maria Bianchi <[EMAIL PROTECTED]> wrote: > > Hello! :) > > I'm trying to run shell commands both with os.system() and > subprocess.Popen() class. > > But I can't run aliases or function defined in my .bashrc file, like in > the login interactive shell. > > Can you help me? > Maybe have I to add some commands to load the .bashrc? > > Thanks a lot! :) > > Ric. > > -- > http://mail.python.org/mailman/listinfo/python-list > you'd need to run an instance of the shell from python and probably as a login shell so that it pulls in .bashrc. so you'd need a command line like: /bin/bash -l -c "shell commands to run go here" if you want to feed more commands to bash, then use -s. It will read commands from standard input, which you would feed it from python, probably by writing to a Popen pipe. A lot of people also use the pexpect python library to "drive" other programs, especially if you need python to act differently depending upon the output of the called programs. Either way, this list's archives do have some good examples as to the uses and limitations of both subprocess and pexpect. -- Noah Dain "The beatings will continue, until morale improves" - the Management -- http://mail.python.org/mailman/listinfo/python-list
Re: Paramiko help - processing multiple commands
>> def storagessh(): >>> paramiko.util.log_to_file(plog) >>> client = paramiko.SSHClient() >>> client.load_system_host_keys() >>> client.connect(hostname, sshport, suser) >>> stdin, stdout, stderr = client.exec_command('show') >>> stdin, stdout, stderr = client.exec_command('help') >>> print stdout.read() >>> client.close() >>> >>> #--Initialization- >>> if __name__ == "__main__": >>> options() >>> storagessh() >> >> Again, as you were asked on the original post -- full tracebacks and >> explain "what is not working". >> >> The use of global variables scares me -- why are those needed? >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > -- > http://mail.python.org/mailman/listinfo/python-list > this works for me: def storagessh(): paramiko.util.log_to_file(plog) client = paramiko.SSHClient() client.load_system_host_keys() client.connect(hostname, sshport, suser) stdin, stdout, stderr = client.exec_command('ps') print stdout.read() stdin, stdout, stderr = client.exec_command('help') print stdout.read() client.close() 1) you reassign stdin, stdout, stderr so with your code you will never see the stdout of the first command ('show') 2) the 'show' command did not exist on my system, so no output. I substituted 'ps' and added the print statement also, using user 'root' for dev code is a Bad Thing. -- Noah Dain -- http://mail.python.org/mailman/listinfo/python-list