dynamically set up ssh -r & paramiko?

2008-01-30 Thread washakie

Hello, I'm trying to write a script which will allow me to initiate (spawn?)
an SSH reverse tunnel from an internal box (inside a firewall) to an
external box, while logged into the external box.
 
I posted to another list and was pointed in the direction of paramiko. I've
read the tutorials, but cannot seem to figure out exactly how I can do
this... I'm hoping someone can look at what I'm trying to do below and
provide an example...

#!/usr/bin/python

import os, time, subprocess
REMOTE_HOME='/my/remote/mount'  #mounted drive to REMOTE_HOME from
LOCAL_MACHINE 

cmd = 'while true; do ssh -R 8022:localhost:22 [EMAIL PROTECTED] ; sleep
60; done'
while 1:
   while os.path.exists(os.path.join(REMOTE_HOME,'mySecretFile'):
   proc= subprocess.call(cmd,shell='True')

   if proc: os.kill(proc.pid)

   if os.path.exists(os.path.join(REMOTE_HOME,'KillScript'):
   break

-- 

Note, I know the reverse tunnel script works on it's own run from the shell,
but I don't want to leave it open always...  furthermore it seems to be a
rather 'brute force' method. It seems paramiko might provide a more elegant
solution! Does anyone have any ideas on how to make this work?

Thanks,
john
-- 
View this message in context: 
http://www.nabble.com/dynamically-set-up-ssh--r---paramiko--tp15193757p15193757.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: find nearest time in datetime list

2008-01-30 Thread washakie

Thanks all! This is terrific, and a quick response... I have to go with the
2.4 version, but thanks to everyone...



Tim Golden-4 wrote:
> 
> washakie wrote:
>> Hello,
>> 
>> I have a list of datetime objects: DTlist, I have another single datetime
>> object: dt, ... I need to find the nearest DTlist[i]  to the dt  is
>> there a simple way to do this? There isn't necessarily an exact match... 
> 
> 
> import datetime
> 
> dates = [datetime.date (2007, 1, (1+i)*2) for i in range (10)]
> one_date = datetime.date (2007, 1, 7)
> 
> print sorted (dates, key=lambda x: abs (x-one_date))[0]
> 
> 
> 
> 
> TJG
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 
> 

-- 
View this message in context: 
http://www.nabble.com/find-nearest-time-in-datetime-list-tp15180398p15183205.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


find nearest time in datetime list

2008-01-30 Thread washakie

Hello,

I have a list of datetime objects: DTlist, I have another single datetime
object: dt, ... I need to find the nearest DTlist[i]  to the dt  is
there a simple way to do this? There isn't necessarily an exact match... 

Thanks!
.john


-- 
View this message in context: 
http://www.nabble.com/find-nearest-time-in-datetime-list-tp15180398p15180398.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: MySQL-python-1.2.2 install with no mysql

2008-01-15 Thread washakie

Thank you...

after:
%yum install mysql* 

I was able to build and install mysql-python


-- 
View this message in context: 
http://www.nabble.com/MySQL-python-1.2.2-install-with-no-mysql-tp14836669p14845579.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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


Re: MySQL-python-1.2.2 install with no mysql

2008-01-15 Thread washakie

Okay, I've installed mysql then using yum... it installed the same version
running on another machine with identical python where all works well... but
now I get this error during build... thoughts?!?? mysql_config is there, and
the site.cfg file is pointing correctly to it... :

[root@ MySQL-python-1.2.2]# python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.linux-i686-2.4/MySQLdb
running build_ext
building '_mysql' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic
-fasynchronous-unwind-tables -D_GNU_SOURCE -fPIC -fPIC
-Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/include/mysql
-I/usr/include/python2.4 -c _mysql.c -o build/temp.linux-i686-2.4/_mysql.o
-g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic
-fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv
_mysql.c:35:23: error: my_config.h: No such file or directory
_mysql.c:40:19: error: mysql.h: No such file or directory
_mysql.c:41:26: error: mysqld_error.h: No such file or directory
_mysql.c:42:20: error: errmsg.h: No such file or directory
_mysql.c:78: error: expected specifier-qualifier-list before ‘MYSQL’
_mysql.c:92: error: expected specifier-qualifier-list before ‘MYSQL_RES’
_mysql.c: In function ‘_mysql_Exception’:
_mysql.c:122: warning: implicit declaration of function ‘mysql_errno’
_mysql.c:122: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c:125: error: ‘CR_MAX_ERROR’ undeclared (first use in this function)
_mysql.c:125: error: (Each undeclared identifier is reported only once
_mysql.c:125: error: for each function it appears in.)
_mysql.c:133: error: ‘CR_COMMANDS_OUT_OF_SYNC’ undeclared (first use in this
function)
_mysql.c:134: error: ‘ER_DB_CREATE_EXISTS’ undeclared (first use in this
function)
_mysql.c:135: error: ‘ER_SYNTAX_ERROR’ undeclared (first use in this
function)
_mysql.c:136: error: ‘ER_PARSE_ERROR’ undeclared (first use in this
function)
_mysql.c:137: error: ‘ER_NO_SUCH_TABLE’ undeclared (first use in this
function)
_mysql.c:138: error: ‘ER_WRONG_DB_NAME’ undeclared (first use in this
function)
_mysql.c:139: error: ‘ER_WRONG_TABLE_NAME’ undeclared (first use in this
function)
_mysql.c:140: error: ‘ER_FIELD_SPECIFIED_TWICE’ undeclared (first use in
this function)
_mysql.c:141: error: ‘ER_INVALID_GROUP_FUNC_USE’ undeclared (first use in
this function)
_mysql.c:142: error: ‘ER_UNSUPPORTED_EXTENSION’ undeclared (first use in
this function)
_mysql.c:143: error: ‘ER_TABLE_MUST_HAVE_COLUMNS’ undeclared (first use in
this function)
_mysql.c:172: error: ‘ER_DUP_ENTRY’ undeclared (first use in this function)
_mysql.c:215: warning: implicit declaration of function ‘mysql_error’
_mysql.c:215: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c:215: warning: passing argument 1 of ‘PyString_FromString’ makes
pointer from integer without a cast
_mysql.c: In function ‘_mysql_server_init’:
_mysql.c:310: warning: label ‘finish’ defined but not used
_mysql.c:236: warning: unused variable ‘item’
_mysql.c:235: warning: unused variable ‘groupc’
_mysql.c:235: warning: unused variable ‘i’
_mysql.c:235: warning: unused variable ‘cmd_argc’
_mysql.c:234: warning: unused variable ‘s’
_mysql.c: In function ‘_mysql_ResultObject_Initialize’:
_mysql.c:365: error: ‘MYSQL_RES’ undeclared (first use in this function)
_mysql.c:365: error: ‘result’ undeclared (first use in this function)
_mysql.c:370: error: ‘MYSQL_FIELD’ undeclared (first use in this function)
_mysql.c:370: error: ‘fields’ undeclared (first use in this function)
_mysql.c:379: error: ‘_mysql_ResultObject’ has no member named ‘use’
_mysql.c:382: warning: implicit declaration of function ‘mysql_use_result’
_mysql.c:382: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c:384: warning: implicit declaration of function ‘mysql_store_result’
_mysql.c:384: error: ‘_mysql_ConnectionObject’ has no member named
‘connection’
_mysql.c:385: error: ‘_mysql_ResultObject’ has no member named ‘result’
_mysql.c:388: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:391: warning: implicit declaration of function ‘mysql_num_fields’
_mysql.c:392: error: ‘_mysql_ResultObject’ has no member named ‘nfields’
_mysql.c:393: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:394: warning: implicit declaration of function ‘mysql_fetch_fields’
_mysql.c:438: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c: In function ‘_mysql_ResultObject_traverse’:
_mysql.c:450: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c:451: error: ‘_mysql_ResultObject’ has no member named ‘converter’
_mysql.c: In function ‘_mysql_ResultObject_clear’:
_mysql.c:462: error: ‘_mysql_ResultO

MySQL-python-1.2.2 install with no mysql

2008-01-15 Thread washakie

Hello,

I need to install the MySQL-python-1.2.2 connector in order to access a db
on another machine. In the install it asks for the location of the
mysql_config file, and if I leave it as the default I get:

[EMAIL PROTECTED] MySQL-python-1.2.2]# python setup.py build
sh: mysql_config: command not found
Traceback (most recent call last):
  File "setup.py", line 16, in ?
metadata, options = get_config()
  File "/opt/MySQL-python-1.2.2/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
  File "/opt/MySQL-python-1.2.2/setup_posix.py", line 24, in mysql_config
raise EnvironmentError, "%s not found" % mysql_config.path
EnvironmentError: mysql_config not found
[EMAIL PROTECTED] MySQL-python-1.2.2]#  

How can I install MySQL-python-1.2.2 without installing MySQL???

thanks!!
-- 
View this message in context: 
http://www.nabble.com/MySQL-python-1.2.2-install-with-no-mysql-tp14836669p14836669.html
Sent from the Python - python-list mailing list archive at Nabble.com.

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