Question about installing python and modules on Red Hat Linux 6

2014-11-14 Thread pythonista
I am developing a python application as a contractor.

I would like to know if someone can provide me with some insight into the 
problems that then infrastructure team has been having.

The scope of the project was to install python 2.7.8 and 4 modules/site 
packages on a fresh linux build.

The first team failed after almost 3 weeks of work.

Then  they put their star Linux administrator on the task and it took almost a 
week of considerable effort.

I was able to perform the same task on my windows desktop in less than a 
morning.

I cannot get a straight answer as to what the problems are.

They just seemed to be building and rebuilding all of the components from 
scratch.

Can anyone provide me with insight as to the scope what the problem could have 
been?

Thanks

-- 
https://mail.python.org/mailman/listinfo/python-list


Python Paramiko between Linux and Windows Server -- no output obtained from Windows for "dir" or "cd" commands

2015-05-31 Thread Pythonista
Hello There:

I am using Python 2.7.6 and Paramiko module (on a Linux server) to connect to a 
Windows server and send some commands and get output. I have a connect function 
which takes IP, username and password of the remote Windows server and I get an 
sshobj when that happens. How do I use it to send remote calls is my question?

If it were a local system, I would just say "os.system" but not sure about the 
remote calls. Can someone help?

My code looks like below: sys.path.append("/home/me/code")

import libs.ssh_connect as ssh
ssh_obj = ssh.new_conn(IP, username, password)

stdin, stdout, stderr = ssh_obj.exec_command("dir") #since the remotesystem 
I am SSHing into is Windows.

my "new_conn" looks like this:

import paramiko
def new_conn(IP, username, password):
ssh_obj = paramiko.SSHClient()
ssh_conn.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_conn.connect(IP, username, password), timeout=30)
return ssh_obj


if I replaced "dir" with "ipconfig" it works fine. I wonder how I can make 
"dir" work - or for that matter.. with "cd /path/to/dir"?


I know for paramiko's ssh connection to work, i need cygwin installed on a 
Windows. Objective is to run commands remotely from a Linux to a Windows server 
and then process the output again on Linux server or on Windows itself.

I am confused because, "ipconfig" sent from Linux to Windows using 
"ssh_obj.exec_command("ipconfig")" works but not "ssh_obj.exec_command("dir")" 
- tried giving the path like "cd C:\Users\Administrator" for cmd or "cd C:" 
followed by "cd Users/Administrator" like in Cygwin. Neither of them work.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Paramiko between Linux and Windows Server -- no output obtained from Windows for "dir" or "cd" commands

2015-05-31 Thread Pythonista
On Sunday, May 31, 2015 at 5:18:53 AM UTC-7, Peter Otten wrote:
> Pythonista wrote:
> 
> > Hello There:
> > 
> > I am using Python 2.7.6 and Paramiko module (on a Linux server) to connect
> > to a Windows server and send some commands and get output. I have a
> > connect function which takes IP, username and password of the remote
> > Windows server and I get an sshobj when that happens. How do I use it to
> > send remote calls is my question?
> > 
> > If it were a local system, I would just say "os.system" but not sure about
> > the remote calls. Can someone help?
> > 
> > My code looks like below: sys.path.append("/home/me/code")
> > 
> > import libs.ssh_connect as ssh
> > ssh_obj = ssh.new_conn(IP, username, password)
> > 
> > stdin, stdout, stderr = ssh_obj.exec_command("dir") #since the remote   
> > system I am SSHing into is Windows.
> > 
> > my "new_conn" looks like this:
> > 
> > import paramiko
> > def new_conn(IP, username, password):
> > ssh_obj = paramiko.SSHClient()
> > ssh_conn.set_missing_host_key_policy(paramiko.AutoAddPolicy())
> > ssh_conn.connect(IP, username, password), timeout=30)
> > return ssh_obj
> > 
> >  
> > if I replaced "dir" with "ipconfig" it works fine. I wonder how I can make
> > "dir" work - or for that matter.. with "cd /path/to/dir"?
> 
> 
> dir is an internal command of the windows shell. Try
> 
> ssh_obj.exec_command("cmd /c dir")
> 
> This will execute the dir command and then close the shell.
> 
> cd is also internal, but I don't think it makes sense to invoke it and then 
> close the shell...
> 
> 
> > I know for paramiko's ssh connection to work, i need cygwin installed on a
> > Windows. Objective is to run commands remotely from a Linux to a Windows
> > server and then process the output again on Linux server or on Windows
> > itself.
> > 
> > I am confused because, "ipconfig" sent from Linux to Windows using
> > "ssh_obj.exec_command("ipconfig")" works but not
> > "ssh_obj.exec_command("dir")" - tried giving the path like "cd
> > C:\Users\Administrator" for cmd or "cd C:" followed by "cd
> > Users/Administrator" like in Cygwin. Neither of them work.

Thanks Peter but I got no output from your suggestion either.!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Paramiko between Linux and Windows Server -- no output obtained from Windows for "dir" or "cd" commands

2015-05-31 Thread Pythonista
On Sunday, May 31, 2015 at 6:20:19 PM UTC-7, Dennis Lee Bieber wrote:
> On Sun, 31 May 2015 13:12:24 -0700 (PDT), Pythonista
>  declaimed the following:
> 
> >
> >Thanks Peter but I got no output from your suggestion either.!
> 
>   From Windows viewpoint, I suspect EACH of the commands you send is
> being executed in a totally new process, with no memory of any commands
> sent previously.
> 
>   As mentioned, "ipconfig" is a separate executable program file, and can
> be run without being tied to a Windows command shell. "dir", "cd", "copy",
> "del", and many similar functions are NOT actual programs but internal
> functions of the Windows command processor.
> 
>   Given the mixed quoting used in this thread I'm not sure just what was
> tried or not.
> -- 
>   Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/

Hi Peter -

So I was trying "ipconfig" and "ls /path/to/dir" back to back. Apparently, I 
needed a sleep inbetween the two, I believe. But if "ls" was used individually, 
it works fine.

Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


Issuing commands using "exec_command()" of paramiko AND also sending commands together

2015-06-02 Thread Pythonista
Using paramiko's exec_command(), i would like to send a command, process its 
output and do it for several other commands. I notice that its not quick enough 
or something like that.

How would I handle that scenario AND also providing multiple commands together 
(there is 1 post on stackoverflow for issuing multiple commands but I am not 
sure if someone has tried it. It didnt work for me!

Thanks!
-- 
https://mail.python.org/mailman/listinfo/python-list


strptime dilemma with Python 2.5

2010-05-30 Thread pythonista
Hello,
I have a date string looking like the following:

 "Sun May 30 07:25:17 2010"

With Python 2.6, the %f is supported (it parses the microseconds), so
that this statement works:

dt = datetime.strptime(s, "%a %b %d %H:%M:%f %Y")

However, with Python 2.5, (which is supported on the live Webfaction
server I'm using), %f is not supported.

 Is there a straightforward way to simply ignore the :17 microseconds
in the original string?

Maybe force it to "00" ? -  but without having to actually change the
original string by removing the ":17" ?

If I simply leave out the ":%f" in the strptime call, I get back a "
 ValueError: time data did not match format:  data=Sun May 30
19:33:54 2010  fmt=%a %b %d %H:%M %Y


Hoping for a simple solution that someone is familiar with
Thanks
Steve
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: strptime dilemma with Python 2.5

2010-05-30 Thread pythonista
You know why it looks like it has seconds and not microseconds?

Because it does, and I'm on something.

Thank you


>
> The date string looks like it has hours, minutes and seconds, not hours,
> minutes and microseconds.

-- 
http://mail.python.org/mailman/listinfo/python-list


Greetings, fellow Pythonistas!

2008-06-02 Thread The Pythonista
Hello, all!

This post is to announce a new Python-oriented blog.  See my .sig for the 
URL.

I also have a question: is there any "official" method for getting listed 
on Planet Python?

Thanks!

A fellow Pythonista

-- 
code.py: A blog about life, the universe, and Python

http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


Assigning to __class__ : bad form?

2008-06-06 Thread The Pythonista
I've been wondering for a while about whether assigning to __class__ is 
bad form or not.  Specifically, I mean doing so when some other method of 
implementing the functionality you're after is available (i.e. using an 
adapter, or something like the strategy pattern).

To give an example and a non-example of what I'm talking about, consider 
the following recipes from the online Python Cookbook:

Ring Buffer: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/68429

In this case, I think the assignment to __class__ just obfuscates things, 
and the example would be better coded as a single class.

On the other hand,

Fast copy of an object having a slow __init__ : http://
aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66507

This seems like a reasonable use case for assigning to __class__ (except 
that it's already implemented in the 'new' module, but, read the Martelli-
bot's comments near the end of the recipe).  I consider this a reasonable 
use case for assigning to __class__, because, short of the 'new' module, 
I don't see any other way to accomplish it.

So, what is the opinion of the broader Python community?  Is code that 
assigns to __class__ just clever trickiness to be avoided, or is it 
sometimes a good thing?

-- 
code.py: A blog about life, the universe, and Python

http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


Change in interactive interpreter?

2008-06-06 Thread The Pythonista
I remember the interactive interpreter used to define the name _ to 
return the value of the last expression that was evaluated.  However, I 
tried it just today and got a NameError.  Is this a change in the 
interpreter or is there a configuration option I need to set to enable it?

Thanks!

-- 
code.py: A blog about life, the universe, and Python

http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


Re: Do this as a list comprehension?

2008-06-06 Thread The Pythonista
On Thu, 05 Jun 2008 23:42:07 -0400, John Salerno wrote:

> Is it possible to write a list comprehension for this so as to produce a
> list of two-item tuples?
> 
> base_scores = range(8, 19)
> score_costs = [0, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3] print zip(base_scores,
> score_costs)
> 

score_costs = [(base_scores[i], score_costs[i]) for i in range (len 
(base_scores))]

But, I'd rather just use zip. :-)

-- 
code.py: A blog about life, the universe, and Python

http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to kill a thread?

2008-06-06 Thread The Pythonista
It's always been my understanding that you can't forcibly kill a thread 
in Python (at least not in a portable way).  The best you can do is 
politely ask it to die, IIRC.

-- 
code.py: A blog about life, the universe, and Python

http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


Re: Change in interactive interpreter?

2008-06-06 Thread The Pythonista
On Fri, 06 Jun 2008 11:36:13 -0700, Gary Herron wrote:
   
> Try again.  I think you'll find it's still there -- although you have to
> execute a something that returns a value before it's set for the first
> time.

That was, indeed the problem.  Boy do I feel silly now. :-)

Thanks

-- 
code.py: A blog about life, the universe, and Python

http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


Re: Any GUI lib wiget is capable of a WYSIWYG editor?

2008-06-25 Thread The Pythonista
On Tue, 24 Jun 2008 14:23:12 +0800, oyster wrote:

> that is an html editor with text and picture, while the picture is
> linked to the local image file.
> 
> for wxPython, the richtextcontrol save the image as en embedded object,
> so it is not my choice
> 
> is there any other GUI lib and/or sample code to do so?
> 
> thanks

Consider TkHtml.  You can find a Tix wrapper for it here:

 http://tix.sourceforge.net/Tixapps/src/Python/TkHtml.py

-- 
code.py: A blog about life, the universe, and Python

http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


Python equivalent of call/cc?

2008-07-09 Thread The Pythonista
Yesterday, I was hacking around a bit, trying to figure out how to 
implement the semantics of call/cc in Python.  Specifically, I wanted to 
translate this Scheme code to equivalent Python:



(define theContinuation #f)
 
 (define (test)
   (let ((i 0))
 (call/cc (lambda (k) (set! theContinuation k)))
 (set! i (+ i 1))
 i))

  (test)
  (theContinuation)
  (theContinuation)



Incidentally, those last three lines evaluate to 1, 2, and 3, 
respectively.

The best Python translation I could come up with was something like this 
(targeted at Python 2.5):


import inspect

theContinuation = None

def call_cc (f):
f (inspect.currentframe().f_back)

def invoke (c):
exec c.f_code in c.f_globals, c.f_locals

def test():
i = 0
call_cc (lambda k: globals().update({'theContinuation' : k }))
i = i + 1
print i

test()
invoke (theContinuation)
invoke (theContinuation)



Now, this code is wrong on a number of levels [I am indeed aware of 
exactly how ugly that lambda is...], but, in particular, my 
continuations / stack frames don't seem to be resuming at the right 
point.  I'd expect invoke (theContinuation) to restart on the line 
immediately following call_cc, but it does not.  Not surprisingly, the 
output is also wrong.  (I get 1, 1, and 1 rather than 1, 2, and 3.)

Can anyone help me by, perhaps pointing out some silly error I made?  
Failing that, can someone show me a working implementation of call/cc 
(preferably based on some form of stack inspection)?

Thanks!
-- 
code.py: A blog about life, the universe, and Python

http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


Building python-svn from source

2008-08-11 Thread The Pythonista
First of all, I apologize if this would be more appropriate for python-
dev, but I don't normally subscribe to that list, and felt it would also 
be of general use, so

I'm having problems building the latest Python 2.6 and 3.0 from 
subversion, and I'm not sure how to resolve the problem.  In each case, 
configure executes without problem, but, when I execute 'make', I get 
this error (the same one for both 2.6 and 3.0):

./Parser/asdl_c.py -h ./Include ./Parser/Python.asdl
Must specify exactly one output file
make: *** [Include/Python-ast.h] Error 1

Am I doing something wrong?  If not, how do I work around this error?

Thanks!

-- 
code.py: A blog about life, the universe, and Python

http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list


Re: Building python-svn from source

2008-08-12 Thread The Pythonista
On Tue, 12 Aug 2008 07:04:41 +0200, Martin v. Löwis wrote:


> For some reason, the getopt module in your host's python cannot process
> the command line options to asdl_c.py correctly.
> 
> What Python version do you have installed in PATH?

Martin,

Thank you so much! In fact, I did have a python executable on my PATH in 
~/bin that was screwing things up.  After I moved it (thus leaving the 
system default python as the only python executable on my PATH), the 
build process went smoothly (except for not being able to find a few 
libraries for some C extensions, but I think I can fix that).

I now have working python2.6 and python3.0 executables to play with, 
thanks to you. :-)
-- 
code.py: A blog about life, the universe, and Python

http://pythonista.wordpress.com
** Posted from http://www.teranews.com **
--
http://mail.python.org/mailman/listinfo/python-list