[issue41103] Removing old buffer support

2021-07-29 Thread Tarun Johar


Tarun Johar  added the comment:

Also filed under https://bugs.python.org/issue44609

PEP 384 and PEP 652 define a stable ABI to be used with Python 3.2 and later.  
On Windows, symbols for the stable ABI are exported from the python3.dll shared 
library.

The following functions are present in Python 3.9 but have been removed from 
Python 3.10b3:

PyObject_AsCharBuffer()
PyObject_AsReadBuffer()
PyObject_AsWriteBuffer()
PyObject_CheckReadBuffer()

Without these functions, an extension cannot utilize the stable ABI to access 
the buffer memory of data structures.  The buffer protocol is suggested as an 
alternative, but the buffer functions PyObject_GetBuffer() and 
PyBuffer_Release() are not present in the stable ABI.

While these two functions may be added to the stable ABI, removal of the four 
functions above makes Python 3.10 incompatible with previous versions.  It is 
requested that the four functions be reinstated and maintained as described in 
PEP 652.

--
nosy: +tarun.johar

___
Python tracker 
<https://bugs.python.org/issue41103>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44609] Buffer support in the stable ABI

2021-07-12 Thread Tarun Johar


New submission from Tarun Johar :

PEP 384 and PEP 652 define a stable ABI to be used with Python 3.2 and later.  
On Windows, symbols for the stable ABI are exported from the python3.dll shared 
library.

The following functions are present in Python 3.9 but have been removed from 
Python 3.10b3:

PyObject_AsCharBuffer()
PyObject_AsReadBuffer()
PyObject_AsWriteBuffer()
PyObject_CheckReadBuffer()

The justification for the removal of these functions was discussed in this 
issue:

https://bugs.python.org/issue41103

Without these functions, an extension cannot utilize the stable ABI to access 
the buffer memory of data structures.  The buffer protocol is suggested as an 
alternative, but the buffer functions PyObject_GetBuffer() and 
PyBuffer_Release() are not present in the stable ABI.

While these two functions may be added to the stable ABI, removal of the four 
functions above makes Python 3.10 incompatible with previous versions.  It is 
requested that the four functions be reinstated and maintained as described in 
PEP 652.

--
components: Build
messages: 397319
nosy: tarun.johar
priority: normal
severity: normal
status: open
title: Buffer support in the stable ABI
type: behavior
versions: Python 3.10

___
Python tracker 
<https://bugs.python.org/issue44609>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43597] robotparser should support specifying SSL context

2021-04-06 Thread Tarun Chinmai Sekar


Tarun Chinmai Sekar  added the comment:

I am writing a web scraper, that runs in a container that has CA-Certificates 
stored in a non-standard location. The Ca-Certificates are managed by Certifi. 
By allowing to override the sslcontext, it is possible for the user to 
construct a sslcontext and pass it in.

--

___
Python tracker 
<https://bugs.python.org/issue43597>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43597] robotparser should support specifying SSL context

2021-03-22 Thread Tarun Chinmai Sekar


Change by Tarun Chinmai Sekar  :


--
pull_requests: +23746
pull_request: https://github.com/python/cpython/pull/24986

___
Python tracker 
<https://bugs.python.org/issue43597>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43597] robotparser should support specifying SSL context

2021-03-22 Thread Tarun Chinmai Sekar


Change by Tarun Chinmai Sekar  :


--
keywords: +patch
pull_requests: +23744
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24984

___
Python tracker 
<https://bugs.python.org/issue43597>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43597] robotparser should support specifying SSL context

2021-03-22 Thread Tarun Chinmai Sekar


New submission from Tarun Chinmai Sekar  :

IMO this could be enhanced by adding a sslcontext parameter to read method

a sample change would it could look like
```
def read(self, sslcontext=None):
"""Reads the robots.txt URL and feeds it to the parser."""
try:
if sslcontext:
   f = urllib.request.urlopen(self.url, context=sslcontext)
else:
   f = urllib.request.urlopen(self.url)
except urllib.error.HTTPError as err:
if err.code in (401, 403):
self.disallow_all = True
elif err.code >= 400 and err.code < 500:
self.allow_all = True
else:
raw = f.read()
self.parse(raw.decode("utf-8").splitlines())

```

Happy to send a PR if this proposal makes sense.

--

___
Python tracker 
<https://bugs.python.org/issue43597>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43597] robotparser should support specifying SSL context

2021-03-22 Thread Tarun Chinmai Sekar


Change by Tarun Chinmai Sekar  :


--
components: +Library (Lib)

___
Python tracker 
<https://bugs.python.org/issue43597>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43597] robotparser should support specifying SSL context

2021-03-22 Thread Tarun Chinmai Sekar


Change by Tarun Chinmai Sekar  :


--
nosy: Tchinmai7
priority: normal
severity: normal
status: open
title: robotparser should support specifying SSL context
type: enhancement
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue43597>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Fwd: Unable to Install Python (3.5.0) Properly

2020-05-17 Thread Tarun Pathak
Oh, My apology ! I should have mentioned the system stats in mail.

Windows 7 , 64 bit
Intel Core 2 duo
C drive free space : 23 GB

Initially,  during installation system is asking for service pack 1
I did that.

Later, it's asking for core.msi, dev.msi etc. Because system is not able to
fetch from the web. The log file contains all these errors.






On Mon, May 18, 2020, 12:50 AM DL Neil via Python-list <
python-list@python.org> wrote:

> On 17/05/20 7:06 PM, Tarun Pathak wrote:
> > -- Forwarded message -
> > From: Tarun Pathak 
> > Date: Sun, May 17, 2020, 12:07 PM
> > Subject: Unable to Install Python (3.5.0) Properly
> > To: 
> >
> >
> >
> > Dear Sir/Madam,
> >
> >   I am trying to install Python for a while.  But failed to do so. Tried
> > with different files as well.
> > Requesting your suggestion to solve this issue.
> >
> > Attached the log file in this email.
> >
> > [image: image.png]
> >
> > Thanking you,
> > Tarun
>
>
> Unfortunately this list does not accept images as attachments. Also, did
> you notice that there is a Python-Tutor Discussion List. It's a good
> place for Python-learners to ask questions.
>
> You do not state the Operating System in-use. So, presuming MS-Windows,
> please advise if the following reference is accurate, and works for you:
> https://docs.python.org/3/using/windows.html
> --
> Regards =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Fwd: Unable to Install Python (3.5.0) Properly

2020-05-17 Thread Tarun Pathak
-- Forwarded message -
From: Tarun Pathak 
Date: Sun, May 17, 2020, 12:07 PM
Subject: Unable to Install Python (3.5.0) Properly
To: 



Dear Sir/Madam,

 I am trying to install Python for a while.  But failed to do so. Tried
with different files as well.
Requesting your suggestion to solve this issue.

Attached the log file in this email.

[image: image.png]

Thanking you,
Tarun
-- 
https://mail.python.org/mailman/listinfo/python-list


How to read webpage

2009-08-01 Thread tarun
Dear All,I want to read a webpage and copy the contents of it in word file.
I tried to write following code:

import urllib2
urllib2.urlopen(http://www.rediff http://www.rediff.com/.com/)

*Error:-*

urllib2.urlopen(http://www.icicibank.com/;)
  File C:\Python25\lib\urllib2.py, line 121, in urlopen
return _opener.open(url, data)
  File C:\Python25\lib\urllib2.py, line 374, in open
response = self._open(req, data)
  File C:\Python25\lib\urllib2.py, line 392, in _open
'_open', req)
  File C:\Python25\lib\urllib2.py, line 353, in _call_chain
result = func(*args)
  File C:\Python25\lib\urllib2.py, line 1100, in http_open
return self.do_open(httplib.HTTPConnection, req)
  File C:\Python25\lib\urllib2.py, line 1075, in do_open
raise URLError(err)
urllib2.URLError: urlopen error (11001, 'getaddrinfo failed')
-- 
http://mail.python.org/mailman/listinfo/python-list


Issue with subprocess Module

2009-04-07 Thread tarun
Hello All,

I've a batch file to be  invoke using a python script. The batch file has
pause, and the time, I need to send some command to the batch file from my
scripts. I placed both, the batch file (test.bat) and the python script
(test.py) in the same folder. And executed 'test.py'

(Please find the source files and error below).

*I get the following error:*
Traceback (most recent call last):
  File string, line 74, in run_nodebug
  File D:\test.py, line 4, in module
proc = subprocess.Popen(my_bat,stdin=subprocess.PIPE)
  File C:\Python25\lib\subprocess.py, line 588, in __init__
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
  File C:\Python25\lib\subprocess.py, line 717, in _get_handles
c2pwrite = self._make_inheritable(c2pwrite)
  File C:\Python25\lib\subprocess.py, line 746, in _make_inheritable
DUPLICATE_SAME_ACCESS)
WindowsError: [Error 6] The handle is invalid

*Python Script:*
*test.py*
import subprocess,os
my_bat = os.getcwd()+'\\test.bat'
proc = subprocess.Popen(my_bat,stdin=subprocess.PIPE)
input = '\n'
proc.communicate(input)

*Batch File*
*test.bat*
echo START'
pause
echo 'END'
Please help me with this issue.

Thanks In Advance,
Tarun
--
http://mail.python.org/mailman/listinfo/python-list


Killing Child Process

2009-02-26 Thread tarun
Hello Group,

I've spwaned a process using os.spwanl. As part of this process, I spwan one
more process, using subprocess.Popen.
After I close the the process spwaned using os.spwanl, the child process
started by it using subprocess.Popen, doesn't get closed.
Is there any way to do this in python 2.5.1?

Thanks,
Tarun
--
http://mail.python.org/mailman/listinfo/python-list


Converting c header file to a python file

2008-12-11 Thread tarun
Hello,

I am looking for a tool/utility by which can convert c header file to a
python file. A typical header file that I want convert looks like:

#ifndef __VAR1
#define __VAR1

#define VAR2  Rev 2
#define VAR3   2L

typedef struct
{


}

#if defined(__cplusplus) || defined(__cplusplus__)
extern C {
#endif

And also function declarations

Thanks,
Tarun
--
http://mail.python.org/mailman/listinfo/python-list


Converting a .xls file to .html

2008-12-03 Thread tarun
Hello All,

I've a .xml file (saved as .xls) that can be opened in Microsoft excel. I
want to write python code that converts this excel file into .html (so that
it can be viewed as is in an explorer).

Can any one help?

Regards,
Tarun
--
http://mail.python.org/mailman/listinfo/python-list


Regarding subprocess module

2008-09-05 Thread tarun
Hello all,

I wrote the following code:

import subprocess,time
cmdExe = C:\\WINDOWS\\system32\\cmd.exe
myProcess = subprocess.Popen(cmdExe,stdin=subprocess.PIPE)
time.sleep(2)
myProcess.stdin.write('cd Desktop\r\n')

I copied the above lines of code to a file and tried executing the python
file from dos box (command prompt) on windows
I want subprocess.Popen to open a new dos box. But it works in the same
window. What should I do to open the subprocess in new window?

Thanks  Regards.
Tarun
--
http://mail.python.org/mailman/listinfo/python-list

Python Query: Related to locking a resource in a multithreaded environment

2008-08-19 Thread tarun
Hello All,

I've a configuration.ini file. This particular can be accessed by several
threads of my application. Each thread can read/write configuration
parameters from/to the configuration.ini file. I am using threading (Rlock)
to lock the resource (configuration.ini file) while accessing it from any
thread. I use the file available at
http://www.voidspace.org.uk/python/configobj.html for read/write.

I did the following in one of my files:

import threading
class Synchronization:
  def __init__(self):
self.mutex = threading.RLock()

Now this I can create instances of the class Synchronization and use
acquire/release to work on the shared resource. But every thread would need
to import this class and hence each thread would create a separate instance
of the class. This means several lock variables. But I think we need a
global lock flag that is accessible across all the threads.

How do i do this?

Please let me know ASAP.

Thanks In Advance,
Tarun
--
http://mail.python.org/mailman/listinfo/python-list

Re: Python Query: Related to locking a resource in a multithreaded environment

2008-08-19 Thread tarun
I think I need something called global interpreter lock which is accessible
to all the threads. But I am not sure how to implement this.


On Tue, Aug 19, 2008 at 11:28 AM, tarun [EMAIL PROTECTED] wrote:

  Hello All,

 I've a configuration.ini file. This particular can be accessed by several
 threads of my application. Each thread can read/write configuration
 parameters from/to the configuration.ini file. I am using threading (Rlock)
 to lock the resource (configuration.ini file) while accessing it from any
 thread. I use the file available at
 http://www.voidspace.org.uk/python/configobj.html for read/write.

 I did the following in one of my files:

 import threading
 class Synchronization:
   def __init__(self):
 self.mutex = threading.RLock()

 Now this I can create instances of the class Synchronization and use
 acquire/release to work on the shared resource. But every thread would need
 to import this class and hence each thread would create a separate instance
 of the class. This means several lock variables. But I think we need a
 global lock flag that is accessible across all the threads.

 How do i do this?

 Please let me know ASAP.

 Thanks In Advance,
 Tarun

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

Code for locking a resource

2008-08-19 Thread tarun
Hello All,

I've a configuration.ini file. This particular can be accessed by several
threads of my application. Each thread can read/write configuration
parameters from/to the configuration.ini file. I am using threading (Rlock)
to lock the resource (configuration.ini file) while accessing it from any
thread. I use the file available at
http://www.voidspace.org.uk/python/configobj.html for read/write.
(configobj.py)

I've used RLock to lock the resource.

I see this error while accessing variables of the configuration.ini file

Exception in thread Thread-3:
Traceback (most recent call last):
  File C:\Python25\lib\threading.py, line 460, in __bootstrap
self.run()
  File F:\abc.py, line 229, in run
option1 = conf['OPT1']
  File F:\configobj.py, line 551, in __getitem__
val = dict.__getitem__(self, key)
KeyError: 'OPT1'

Exception in thread Thread-1:
Traceback (most recent call last):
  File C:\Python25\lib\threading.py, line 460, in __bootstrap
self.run()
  File F:\def.py, line 130, in run
option2 = self.conf['OPT2']
  File F:\configobj.py, line 551, in __getitem__
val = dict.__getitem__(self, key)
KeyError: 'OPT2'

Can any one help me with a code for locking a resource across threads.

One more observation. I tried the following code on Python Idle

 import threading
 threading.RLock()
_RLock(None, 0)
 threading.Lock()
thread.lock object at 0x019350B0

Why does threading.RLock() return None

Thanks In Advance,
Tarun
--
http://mail.python.org/mailman/listinfo/python-list

Some issue with right click in TreeCtrl

2008-05-07 Thread tarun
Hello All,

Please find the code for a simple wx.TreeCtrl code. Whenever I right click
on any item in the Tree, I see the function, 'OnSelChanged' gets called
twice.

What I've just done is that I've associated the function 'OnRightClick' with
wx.EVT_TREE_ITEM_RIGHT_CLICK. And in this function, I say
self.tree.SelectItem(evt.GetItem(),True) to select the item and then so some
action for right click.

Can any one help.

Thanks  Regards,
Tarun

*Please find the code in the attachment and also below:-*

import wx
tests = [All Tests,
  [Suite1,
test01,
 test02,
 [suite2,test03,test04],
test05,
  ],
  [Suite3,
test06,
test07
  ],
  [Suite4,
test08,
test09
  ],
  test10,
  test11,
]
class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title=Simple Tree, size=(400,500))
# Create the tree
self.tree = wx.TreeCtrl(self)
# Add a root node
root = self.tree.AddRoot(tests[0])
# Add nodes from our data set
self.AddTreeNodes(root, tests, 0)
# Bind some interesting events
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.tree)
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnRightClick,
self.tree)
# Expand the first level
self.tree.Expand(root)

def AddTreeNodes(self, father, aTestList,count):
if type(aTestList) == type([]):
l = len(aTestList)
i = 0
while i  l:
if i == 0:
if count ==1:
father = self.tree.AppendItem(father, aTestList[i])
else:
self.AddTreeNodes(father, aTestList[i],
1)
i = i + 1
if type(aTestList) == type():
self.tree.AppendItem(father, aTestList)

def OnRightClick(self, evt):
self.tree.SelectItem(evt.GetItem(),True)
print 'In OnRightClick Function...',self.GetItemText(evt.GetItem())

def GetItemText(self, item):
if item:
return self.tree.GetItemText(item)
else:
return 

def OnSelChanged(self, evt):
print OnSelChanged:   , self.GetItemText(evt.GetItem())

app = wx.PySimpleApp(redirect=True)
frame = TestFrame()
frame.Show()
app.MainLoop()
import wx

tests = [All Tests, 
[Suite1,
 test01,
 test02,
 [suite2,test03,test04],
 test05, 
],
[Suite3,
 test06,  
 test07
],
[Suite4,  
 test08,
 test09
],  
test10,
test11,
]

class TestFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, None, title=Simple Tree, size=(400,500))

# Create the tree
self.tree = wx.TreeCtrl(self)

# Add a root node   
root = self.tree.AddRoot(tests[0])

# Add nodes from our data set
self.AddTreeNodes(root, tests, 0)

# Bind some interesting events
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelChanged, self.tree)
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnRightClick, self.tree)

# Expand the first level
self.tree.Expand(root)

def AddTreeNodes(self, father, aTestList,count):
if type(aTestList) == type([]): 
l = len(aTestList)
i = 0
while i  l:
if i == 0: 
if count ==1:
father = self.tree.AppendItem(father, aTestList[i])
else:
self.AddTreeNodes(father, aTestList[i], 1) 
i = i + 1

if type(aTestList) == type():
self.tree.AppendItem(father, aTestList)

def OnRightClick(self, evt):
self.tree.SelectItem(evt.GetItem(),True) 
print 'In OnRightClick Function...',self.GetItemText(evt.GetItem())

def GetItemText(self, item):
if item:
return self.tree.GetItemText(item)
else:
return  
  
def OnSelChanged(self, evt):
print OnSelChanged:   , self.GetItemText(evt.GetItem())

app = wx.PySimpleApp(redirect=True)
frame = TestFrame()
frame.Show()
app.MainLoop()--
http://mail.python.org/mailman/listinfo/python-list

Related to Shelve Module

2008-04-27 Thread tarun
Hi All,
I want to store the class instance object variables persistenlty in one file
so that other file can also access for some filtering. I tired doing this
using the shelve module.

*Code:*
class A:
pass

import shelve
filename = 'test.db'
d = shelve.open(filename)

a = A()
print a
d['1'] = a

print d['1']
d.close()

*Output:*
__main__.A instance at 0x018B56C0
__main__.A instance at 0x018B5760

*Observation:*
I expect both the print statements to return the same value, The second
print statement just reads the dictonary, but still the adress (0x..) is
different from the first print statement. Can anyone tell me why. Also let
me know if you the way of getting same value both the times.

Quick help will be appreciated.

Thanks  Regards,
Tarun
--
http://mail.python.org/mailman/listinfo/python-list

Issues with Python + Batch File

2008-03-25 Thread tarun
Hi All,
I've a batch file which invoks a python file. The python code in the file
brings up a GUI. The GUI is of a test tool which can execute scripts.

I tried using the following 2 sample of code for my batch file:

* (1)   (2)*
D:\opengui.py  D:\opengui.py
goto:end   goto:end
:end   :end
EXIT   TASKKILL /IM C:\WINDOWS\system32\cmd.exe

Double clicking on the batch file brings up a DOS BOX which opens up the
GUI. On Closing the GUI, the DOS BOX both get closed. But if I close the GUI
when a test is under execution, the GUI gets closed but the DOS BOX still
remains open.

I want to some how close the DOS BOX when the GUI is closed.

Thanks  Regards,
Tarun
[EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Paramiko bugs out on windows 2003 server

2008-03-24 Thread Tarun Kapoor
I am using the paramiko library to pull a data from a server using SFTP.
It works perfect on a windows xp machine but bugs out a windows 2003
server. I get the following error:
Traceback (most recent call last):
  File S:\Temp\ftpBOA.py, line 5, in ?
import paramiko
  File C:\Python23\lib\paramiko\__init__.py, line 69, in ?
from transport import randpool, SecurityOptions, Transport
  File C:\Python23\lib\paramiko\transport.py, line 32, in ?
from paramiko import util
  File C:\Python23\lib\paramiko\util.py, line 31, in ?
from paramiko.common import *
  File C:\Python23\lib\paramiko\common.py, line 98, in ?
from osrandom import OSRandomPool
  File C:\Python23\lib\paramiko\osrandom.py, line 54, in ?
raise ImportError(Cannot find OS entropy source)
ImportError: Cannot find OS entropy source

Anyone knows how to solve it ?
Tarun Kapoor



Disclaimer

This e-mail and any attachments is confidential and intended solely for the use 
of the individual(s) to whom it is addressed. Any views or opinions presented 
are solely those of the author and do not necessarily represent those of 
Waterstone Capital Management, L.P and affiliates. If you are not the intended 
recipient, be advised that you have received this e-mail in error and that any 
use, dissemination, printing, forwarding or copying of this email is strictly 
prohibited. Please contact the sender if you have received this e-mail in 
error. You should also be aware that e-mails are susceptible to interference 
and you should not assume that the contents of this e-mail originated from the 
sender above or that they have been accurately reproduced in their original 
form. Waterstone Capital Management, L.P. and affiliates accepts no 
responsibility for information, or errors or omissions in this e-mail or use or 
misuse thereof. If in doubt, please verify the authenticity with the!
  sender.


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


RE: paramiko

2008-03-20 Thread Tarun Kapoor
I have some code that uses paramiko, establishes an SFTP connection with
a remote server and downloads some files. This code works perfect if run
on a windows XP machine. However, I get an error in the RandomPool
class. 
Anyone tried paramiko on a windows server box ?
Thanks !!
Tk


-Original Message-
From: Guilherme Polo [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, January 16, 2008 11:12 AM
To: Tarun Kapoor; python-list@python.org
Subject: Re: paramiko

2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:




 I am using paramiko to do an SFTP file transfer... I was able to
connect to
 the remote server using an SFTP client I have just to make sure that
 username and password are working.. This is the code.



 # now, connect and use paramiko Transport to negotiate SSH2 across
the
 connection

 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

 sock.connect((hostname, port))



 t = paramiko.Transport(sock)

 event = threading.Event()

 t.start_client(event)



 event.wait(15)



 if not t.is_active():

 print 'SSH negotiation failed.'

 sys.exit(1)

 else:

 print SSH negotiation sucessful



 event.clear()



 t.auth_password(username=username, password=password,event=event)



 if not t.is_authenticated():

 print not authenticated

 output:

 SSH negotiation successful

 not authenticated







 Tarun



 Waterstone Capital Management

 2 Carlson Parkway, Suite 260

 Plymouth, MN 55447



 Direct: 952-697-4123

 Cell:612-205-2587
  Disclaimer This e-mail and any attachments is confidential and
intended
 solely for the use of the individual(s) to whom it is addressed. Any
views
 or opinions presented are solely those of the author and do not
necessarily
 represent those of Waterstone Capital Management, L.P and affiliates.
If you
 are not the intended recipient, be advised that you have received this
 e-mail in error and that any use, dissemination, printing, forwarding
or
 copying of this email is strictly prohibited. Please contact the
sender if
 you have received this e-mail in error. You should also be aware that
 e-mails are susceptible to interference and you should not assume that
the
 contents of this e-mail originated from the sender above or that they
have
 been accurately reproduced in their original form. Waterstone Capital
 Management, L.P. and affiliates accepts no responsibility for
information,
 or errors or omissions in this e-mail or use or misuse thereof. If in
doubt,
 please verify the authenticity with the sender.
 --
 http://mail.python.org/mailman/listinfo/python-list


You are missing an event.wait() after t.auth_password.
Also, why are you passing this magic value 15 to event.wait() ? That
parameter is passed to class _Verbose to indicate if debug messages
should be displayed or not, so typical values would be 0/1 or
False/True.

-- 
-- Guilherme H. Polo Goncalves


Disclaimer

This e-mail and any attachments is confidential and intended solely for the use 
of the individual(s) to whom it is addressed. Any views or opinions presented 
are solely those of the author and do not necessarily represent those of 
Waterstone Capital Management, L.P and affiliates. If you are not the intended 
recipient, be advised that you have received this e-mail in error and that any 
use, dissemination, printing, forwarding or copying of this email is strictly 
prohibited. Please contact the sender if you have received this e-mail in 
error. You should also be aware that e-mails are susceptible to interference 
and you should not assume that the contents of this e-mail originated from the 
sender above or that they have been accurately reproduced in their original 
form. Waterstone Capital Management, L.P. and affiliates accepts no 
responsibility for information, or errors or omissions in this e-mail or use or 
misuse thereof. If in doubt, please verify the authenticity with the!
  sender.


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


Scroll Bar in List Ctrl

2008-01-28 Thread tarun
Hi All,

I've a listcontrol in a frame, wherein data gets poupulated and when the
data is more than the veritcal size of the listcontrol window, a vertical
scroll bar comes up automatically. But it always stays at the top. but i
want it be at the bottom to be able to see the latest updates always.

Can any one help

Thanks,
Tarun Devnani
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: [wxPython-users] Issue with docking wx.listctrl window

2008-01-27 Thread tarun
Thanks Robin.
Can you please elobrate more on this.

Regards,
Tarun Devnani
On Jan 25, 2008 10:24 PM, Robin Dunn [EMAIL PROTECTED] wrote:

 tarun wrote:
  Thanks a lot Robin.
 
  I tried using self.log and instead of self.log.list. *Code is attached.*
  But this gives me a panel and listctrl in it. The extra blank space
  around the listctrl in window1 is something that I don't need.

 Use a sizer to manage the layout of the listctrl.

 --
  Robin Dunn
 Software Craftsman
 http://wxPython.org http://wxpython.org/  Java give you jitters?  Relax
 with wxPython!


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

Re: [wxPython-users] Issue with docking wx.listctrl window

2008-01-27 Thread tarun
Robin,
I can use sizers and divide my frames into sections. But I also want to add
menu options for display/hide window1 and window2 in my original example. Is
this possible even if I use sizers.

Regards,
Tarun
On Jan 28, 2008 1:09 PM, tarun [EMAIL PROTECTED] wrote:

 Thanks Robin.
 Can you please elobrate more on this.

 Regards,
 Tarun Devnani
   On Jan 25, 2008 10:24 PM, Robin Dunn [EMAIL PROTECTED] wrote:

  tarun wrote:
   Thanks a lot Robin.
  
   I tried using self.log and instead of self.log.list. *Code is
  attached.*
   But this gives me a panel and listctrl in it. The extra blank space
   around the listctrl in window1 is something that I don't need.
 
  Use a sizer to manage the layout of the listctrl.
 
  --
   Robin Dunn
  Software Craftsman
  http://wxPython.org http://wxpython.org/  Java give you jitters?
   Relax with wxPython!
 
 

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

Re: [wxPython-users] Issue with docking wx.listctrl window

2008-01-24 Thread tarun
Thanks a lot Robin.

I tried using self.log and instead of self.log.list. *Code is attached.* But
this gives me a panel and listctrl in it. The extra blank space around the
listctrl in window1 is something that I don't need.

Please help.

Regards,
Tarun Devnani
On Jan 24, 2008 11:28 PM, Robin Dunn [EMAIL PROTECTED] wrote:

  tarun wrote:
  Hello All,
 
  I'm trying to create a Frame with AuiManager. The code is attached.
 
  *Problem:*
  - I want 2 windows to be docked in the frame. One is a text control and
  other is a list control.
  - The text control gets docked, but on trying to dock the list control,
  all the tabs dis-appear.
The tabs appear only when the list control window is kept floating.
 
  In the attached code the list control window is kept floating. This can
  be docked
  To see the issue with docking, comment line 33 and un-comment line 35 in
  the attached file and then try to execute, the issue would be clearly
  visible. On un-docking the window1, the tabs again appear..
 
  *Please let  me the solution to this ASAP*


 The main problem is that you are putting the listctrl on a panel, but
 you are telling AUI to manage the listctrl, not the panel.  If I
 understand correctly then your other problems stem from that as well.
 Try passing self.log to AddPane, instead of self.log.list.


 --
 Robin Dunn
 Software Craftsman
 http://wxPython.org http://wxpython.org/  Java give you jitters?  Relax
 with wxPython!


import wx
import wx.aui
from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin

class AutoWidthListCtrl(wx.ListCtrl, ListCtrlAutoWidthMixin):
def __init__(self, parent):
wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT)
ListCtrlAutoWidthMixin.__init__(self)

class Log(wx.Panel):
def __init__(self, parent,id):
wx.Panel.__init__(self, parent, id) 
list = AutoWidthListCtrl(self)
list.InsertColumn(0, 'Tab1',width=60)
list.InsertColumn(1, 'Tab2',width=60)
list.InsertColumn(2, 'Tab3', width=60)
list.InsertColumn(3, 'Tab4', width=60)
list.InsertColumn(4, 'Tab5', width=60)
list.InsertColumn(5, 'Tab6', width=60)
self.list = list

class Test(wx.Frame):
def __init__(self, parent,id =-1, title='Test'): 
wx.Frame.__init__(self, parent, id, title, size = (400, 600))

def MakeAll(self):
self._mgr = wx.aui.AuiManager(self)
self.log = Log(self,-1)

self.list = wx.TextCtrl(self, -1,style = 
wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
self._mgr.AddPane(self.list, 
wx.aui.AuiPaneInfo().Bottom().Caption(Window2).MinSize((-1, 
100)).FloatingSize(wx.Size(400, 100)).CloseButton(False).MaximizeButton(False))
# The line below creates a list control window is created that is 
floating
#self._mgr.AddPane(self.log.list, 
wx.aui.AuiPaneInfo().Bottom().MinSize((-1, 
100)).Caption(Window1).Float().FloatingSize(wx.Size(400, 
100)).CloseButton(False).MaximizeButton(False))
# The line below if uncommented and the line above commented, a list 
control window is craeted that is docked
#self._mgr.AddPane(self.log.list, 
wx.aui.AuiPaneInfo().Bottom().MinSize((-1, 
100)).Caption(Window1).FloatingSize(wx.Size(400, 
100)).CloseButton(False).MaximizeButton(False))
self._mgr.AddPane(self.log, wx.aui.AuiPaneInfo().Bottom().MinSize((-1, 
100)).Caption(Window1).FloatingSize(wx.Size(400, 
100)).CloseButton(False).MaximizeButton(False))
self._mgr.Update()

app_main = wx.PySimpleApp()
frame = Test(None)
frame.MakeAll()
frame.Show()
app_main.MainLoop()
-- 
http://mail.python.org/mailman/listinfo/python-list

Issue with docking wx.listctrl window

2008-01-23 Thread tarun
Hello All,

I'm trying to create a Frame with AuiManager. The code is attached.

*Problem:*
- I want 2 windows to be docked in the frame. One is a text control and
other is a list control.
- The text control gets docked, but on trying to dock the list control, all
the tabs dis-appear.
  The tabs appear only when the list control window is kept floating.

In the attached code the list control window is kept floating. This can be
docked
To see the issue with docking, comment line 33 and un-comment line 35 in the
attached file and then try to execute, the issue would be clearly visible.
On un-docking the window1, the tabs again appear..

*Please let  me the solution to this ASAP*
import wx
import wx.aui
from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin

class AutoWidthListCtrl(wx.ListCtrl, ListCtrlAutoWidthMixin):
def __init__(self, parent):
wx.ListCtrl.__init__(self, parent, -1, style=wx.LC_REPORT)
ListCtrlAutoWidthMixin.__init__(self)

class Log(wx.Panel):
def __init__(self, parent,id):
wx.Panel.__init__(self, parent, id) 
list = AutoWidthListCtrl(self)
list.InsertColumn(0, 'Tab1',width=60)
list.InsertColumn(1, 'Tab2',width=60)
list.InsertColumn(2, 'Tab3', width=60)
list.InsertColumn(3, 'Tab4', width=60)
list.InsertColumn(4, 'Tab5', width=60)
list.InsertColumn(5, 'Tab6', width=60)
self.list = list

class Test(wx.Frame):
def __init__(self, parent,id =-1, title='Test'): 
wx.Frame.__init__(self, parent, id, title, size = (400, 600))

def MakeAll(self):
self._mgr = wx.aui.AuiManager(self)
self.log = Log(self,-1)

self.list = wx.TextCtrl(self, -1,style = 
wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
self._mgr.AddPane(self.list, 
wx.aui.AuiPaneInfo().Bottom().Caption(Window2).MinSize((-1, 
100)).FloatingSize(wx.Size(400, 100)).CloseButton(False).MaximizeButton(False))
# The line below creates a list control window is created that is 
floating
self._mgr.AddPane(self.log.list, 
wx.aui.AuiPaneInfo().Bottom().MinSize((-1, 
100)).Caption(Window1).Float().FloatingSize(wx.Size(400, 
100)).CloseButton(False).MaximizeButton(False))
# The line below if uncommented and the line above commented, a list 
control window is craeted that is docked
#self._mgr.AddPane(self.log.list, 
wx.aui.AuiPaneInfo().Bottom().MinSize((-1, 
100)).Caption(Window1).FloatingSize(wx.Size(400, 
100)).CloseButton(False).MaximizeButton(False))
self._mgr.Update()

app_main = wx.PySimpleApp()
frame = Test(None)
frame.MakeAll()
frame.Show()
app_main.MainLoop()
-- 
http://mail.python.org/mailman/listinfo/python-list

Paramiko/SSH blues....

2008-01-16 Thread Tarun Kapoor
I am using paramiko to do an SFTP file transfer... I was able to connect
to the remote server using an SFTP client I have just to make sure
that username and password are working.. But when i try to connect
using this script it fails 

**hostname, username and password are declared.

# now, connect and use paramiko Transport to negotiate SSH2 across
the connection
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((hostname, port))

t = paramiko.Transport(sock)
event = threading.Event()
t.start_client(event)

event.wait(15)

if not t.is_active():
print 'SSH negotiation failed.'
sys.exit(1)
else:
print SSH negotiation sucessful

event.clear()

t.auth_password(username=username, password=password,event=event)

if not t.is_authenticated():
print not authenticated
output:
SSH negotiation successful
not authenticated

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


paramiko

2008-01-16 Thread Tarun Kapoor
I am using paramiko to do an SFTP file transfer... I was able to connect
to the remote server using an SFTP client I have just to make sure that
username and password are working.. This is the code.

   

# now, connect and use paramiko Transport to negotiate SSH2 across
the connection

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

sock.connect((hostname, port))



t = paramiko.Transport(sock)

event = threading.Event()

t.start_client(event)

 

event.wait(15)

 

if not t.is_active():

print 'SSH negotiation failed.'

sys.exit(1)

else:

print SSH negotiation sucessful

 

event.clear()



t.auth_password(username=username, password=password,event=event)

 

if not t.is_authenticated():

print not authenticated

output:

SSH negotiation successful

not authenticated

 

 

 

Tarun

 

Waterstone Capital Management

2 Carlson Parkway, Suite 260

Plymouth, MN 55447

 

Direct: 952-697-4123

Cell:612-205-2587



Disclaimer

This e-mail and any attachments is confidential and intended solely for the use 
of the individual(s) to whom it is addressed. Any views or opinions presented 
are solely those of the author and do not necessarily represent those of 
Waterstone Capital Management, L.P and affiliates. If you are not the intended 
recipient, be advised that you have received this e-mail in error and that any 
use, dissemination, printing, forwarding or copying of this email is strictly 
prohibited. Please contact the sender if you have received this e-mail in 
error. You should also be aware that e-mails are susceptible to interference 
and you should not assume that the contents of this e-mail originated from the 
sender above or that they have been accurately reproduced in their original 
form. Waterstone Capital Management, L.P. and affiliates accepts no 
responsibility for information, or errors or omissions in this e-mail or use or 
misuse thereof. If in doubt, please verify the authenticity with the sender.

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

Re: paramiko

2008-01-16 Thread Tarun Kapoor
# now, connect and use paramiko Transport to negotiate SSH2 across
the connection
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((hostname, port))

t = paramiko.Transport(sock)
t.start_client()
key = t.get_remote_server_key()

event = threading.Event()
t.auth_password(username=username, password=password, event=event)
event.wait()

if not t.is_authenticated():
print not authenticated

output:
not authenticated




On Jan 16, 11:11 am, Guilherme Polo [EMAIL PROTECTED] wrote:
 2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:





  I am using paramiko to do an SFTP file transfer... I was able to connect to
  the remote server using an SFTP client I have just to make sure that
  username and password are working.. This is the code.

  # now, connect and use paramiko Transport to negotiate SSH2 across the
  connection

  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

  sock.connect((hostname, port))

  t = paramiko.Transport(sock)

  event = threading.Event()

  t.start_client(event)

  event.wait(15)

  if not t.is_active():

  print 'SSH negotiation failed.'

  sys.exit(1)

  else:

  print SSH negotiation sucessful

  event.clear()

  t.auth_password(username=username, password=password,event=event)

  if not t.is_authenticated():

  print not authenticated

  output:

  SSH negotiation successful

  not authenticated

  Tarun

  Waterstone Capital Management

  2 Carlson Parkway, Suite 260

  Plymouth, MN 55447

  Direct: 952-697-4123

  Cell:612-205-2587
   Disclaimer This e-mail and any attachments is confidential and intended
  solely for the use of the individual(s) to whom it is addressed. Any views
  or opinions presented are solely those of the author and do not necessarily
  represent those of Waterstone Capital Management, L.P and affiliates. If you
  are not the intended recipient, be advised that you have received this
  e-mail in error and that any use, dissemination, printing, forwarding or
  copying of this email is strictly prohibited. Please contact the sender if
  you have received this e-mail in error. You should also be aware that
  e-mails are susceptible to interference and you should not assume that the
  contents of this e-mail originated from the sender above or that they have
  been accurately reproduced in their original form. Waterstone Capital
  Management, L.P. and affiliates accepts no responsibility for information,
  or errors or omissions in this e-mail or use or misuse thereof. If in doubt,
  please verify the authenticity with the sender.
  --
 http://mail.python.org/mailman/listinfo/python-list

 You are missing an event.wait() after t.auth_password.
 Also, why are you passing this magic value 15 to event.wait() ? That
 parameter is passed to class _Verbose to indicate if debug messages
 should be displayed or not, so typical values would be 0/1 or
 False/True.

 --
 -- Guilherme H. Polo Goncalves

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


Re: paramiko

2008-01-16 Thread Tarun Kapoor
On Jan 16, 11:38 am, Guilherme Polo [EMAIL PROTECTED] wrote:
 2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:



  # now, connect and use paramiko Transport to negotiate SSH2 across
  the connection
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  sock.connect((hostname, port))

  t = paramiko.Transport(sock)
  t.start_client()
  key = t.get_remote_server_key()

  event = threading.Event()
  t.auth_password(username=username, password=password, event=event)
  event.wait()

  if not t.is_authenticated():
  print not authenticated

  output:
  not authenticated

 This is a different problem I guess, now you are usin get_remote_server_key.
 And why are you creating event after calling start_client without
 specifying it ?





  On Jan 16, 11:11 am, Guilherme Polo [EMAIL PROTECTED] wrote:
   2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:

I am using paramiko to do an SFTP file transfer... I was able to 
connect to
the remote server using an SFTP client I have just to make sure that
username and password are working.. This is the code.

# now, connect and use paramiko Transport to negotiate SSH2 across 
the
connection

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

sock.connect((hostname, port))

t = paramiko.Transport(sock)

event = threading.Event()

t.start_client(event)

event.wait(15)

if not t.is_active():

print 'SSH negotiation failed.'

sys.exit(1)

else:

print SSH negotiation sucessful

event.clear()

t.auth_password(username=username, password=password,event=event)

if not t.is_authenticated():

print not authenticated

output:

SSH negotiation successful

not authenticated

Tarun

Waterstone Capital Management

2 Carlson Parkway, Suite 260

Plymouth, MN 55447

Direct: 952-697-4123

Cell:612-205-2587
 Disclaimer This e-mail and any attachments is confidential and intended
solely for the use of the individual(s) to whom it is addressed. Any 
views
or opinions presented are solely those of the author and do not 
necessarily
represent those of Waterstone Capital Management, L.P and affiliates. 
If you
are not the intended recipient, be advised that you have received this
e-mail in error and that any use, dissemination, printing, forwarding or
copying of this email is strictly prohibited. Please contact the sender 
if
you have received this e-mail in error. You should also be aware that
e-mails are susceptible to interference and you should not assume that 
the
contents of this e-mail originated from the sender above or that they 
have
been accurately reproduced in their original form. Waterstone Capital
Management, L.P. and affiliates accepts no responsibility for 
information,
or errors or omissions in this e-mail or use or misuse thereof. If in 
doubt,
please verify the authenticity with the sender.
--
   http://mail.python.org/mailman/listinfo/python-list

   You are missing an event.wait() after t.auth_password.
   Also, why are you passing this magic value 15 to event.wait() ? That
   parameter is passed to class _Verbose to indicate if debug messages
   should be displayed or not, so typical values would be 0/1 or
   False/True.

   --
   -- Guilherme H. Polo Goncalves

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

 --
 -- Guilherme H. Polo Goncalves


ok here is the problem... I don't know what is the correct way... The
only demos i have from the paramiko library use a hostkeyfile. since i
don't have that i thought i would use the get_remote_key to get the
key and then connect it using the code in the demo.. But clearly
nothing is working...I should not HAVE to use the key since i should
be able to authenticate using the password...

Can you please suggest the right way to go ?

Thanks for your time !
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: paramiko

2008-01-16 Thread Tarun Kapoor
On Jan 16, 12:22 pm, Guilherme Polo [EMAIL PROTECTED] wrote:
 2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:



  On Jan 16, 11:38 am, Guilherme Polo [EMAIL PROTECTED] wrote:
   2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:

# now, connect and use paramiko Transport to negotiate SSH2 across
the connection
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect((hostname, port))

t = paramiko.Transport(sock)
t.start_client()
key = t.get_remote_server_key()

event = threading.Event()
t.auth_password(username=username, password=password, event=event)
event.wait()

if not t.is_authenticated():
print not authenticated

output:
not authenticated

   This is a different problem I guess, now you are usin 
   get_remote_server_key.
   And why are you creating event after calling start_client without
   specifying it ?

On Jan 16, 11:11 am, Guilherme Polo [EMAIL PROTECTED] wrote:
 2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:

  I am using paramiko to do an SFTP file transfer... I was able to 
  connect to
  the remote server using an SFTP client I have just to make sure that
  username and password are working.. This is the code.

  # now, connect and use paramiko Transport to negotiate SSH2 
  across the
  connection

  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

  sock.connect((hostname, port))

  t = paramiko.Transport(sock)

  event = threading.Event()

  t.start_client(event)

  event.wait(15)

  if not t.is_active():

  print 'SSH negotiation failed.'

  sys.exit(1)

  else:

  print SSH negotiation sucessful

  event.clear()

  t.auth_password(username=username, 
  password=password,event=event)

  if not t.is_authenticated():

  print not authenticated

  output:

  SSH negotiation successful

  not authenticated

  Tarun

  Waterstone Capital Management

  2 Carlson Parkway, Suite 260

  Plymouth, MN 55447

  Direct: 952-697-4123

  Cell:612-205-2587
   Disclaimer This e-mail and any attachments is confidential and 
  intended
  solely for the use of the individual(s) to whom it is addressed. 
  Any views
  or opinions presented are solely those of the author and do not 
  necessarily
  represent those of Waterstone Capital Management, L.P and 
  affiliates. If you
  are not the intended recipient, be advised that you have received 
  this
  e-mail in error and that any use, dissemination, printing, 
  forwarding or
  copying of this email is strictly prohibited. Please contact the 
  sender if
  you have received this e-mail in error. You should also be aware 
  that
  e-mails are susceptible to interference and you should not assume 
  that the
  contents of this e-mail originated from the sender above or that 
  they have
  been accurately reproduced in their original form. Waterstone 
  Capital
  Management, L.P. and affiliates accepts no responsibility for 
  information,
  or errors or omissions in this e-mail or use or misuse thereof. If 
  in doubt,
  please verify the authenticity with the sender.
  --
 http://mail.python.org/mailman/listinfo/python-list

 You are missing an event.wait() after t.auth_password.
 Also, why are you passing this magic value 15 to event.wait() ? That
 parameter is passed to class _Verbose to indicate if debug messages
 should be displayed or not, so typical values would be 0/1 or
 False/True.

 --
 -- Guilherme H. Polo Goncalves

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

   --
   -- Guilherme H. Polo Goncalves

  ok here is the problem... I don't know what is the correct way... The
  only demos i have from the paramiko library use a hostkeyfile. since i
  don't have that i thought i would use the get_remote_key to get the
  key and then connect it using the code in the demo.. But clearly
  nothing is working...I should not HAVE to use the key since i should
  be able to authenticate using the password...

  Can you please suggest the right way to go ?

 You don't need to use key to authenticate using username and password,
 indeed. And you don't. Your first email was almost correct, you just
 needed to add event.wait() after t.auth_password. It worked here after
 doing that change. You can check out my version:

 import sys
 import socket
 import paramiko
 import threading

 if len(sys.argv) != 4:
 print %s hostname user password % sys.argv[0]
 sys.exit(1)

 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 sock.connect((sys.argv[1], 22))

 t = paramiko.Transport(sock)
 event = threading.Event()
 t.start_client(event)

 event.wait()

 if not t.is_active

Re: paramiko

2008-01-16 Thread Tarun Kapoor
On Jan 16, 1:56 pm, Guilherme Polo [EMAIL PROTECTED] wrote:
 2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:



  On Jan 16, 12:22 pm, Guilherme Polo [EMAIL PROTECTED] wrote:
   2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:

On Jan 16, 11:38 am, Guilherme Polo [EMAIL PROTECTED] wrote:
 2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:

  # now, connect and use paramiko Transport to negotiate SSH2 
  across
  the connection
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  sock.connect((hostname, port))

  t = paramiko.Transport(sock)
  t.start_client()
  key = t.get_remote_server_key()

  event = threading.Event()
  t.auth_password(username=username, password=password, 
  event=event)
  event.wait()

  if not t.is_authenticated():
  print not authenticated

  output:
  not authenticated

 This is a different problem I guess, now you are usin 
 get_remote_server_key.
 And why are you creating event after calling start_client without
 specifying it ?

  On Jan 16, 11:11 am, Guilherme Polo [EMAIL PROTECTED] wrote:
   2008/1/16, Tarun Kapoor [EMAIL PROTECTED]:

I am using paramiko to do an SFTP file transfer... I was able 
to connect to
the remote server using an SFTP client I have just to make sure 
that
username and password are working.. This is the code.

# now, connect and use paramiko Transport to negotiate SSH2 
across the
connection

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

sock.connect((hostname, port))

t = paramiko.Transport(sock)

event = threading.Event()

t.start_client(event)

event.wait(15)

if not t.is_active():

print 'SSH negotiation failed.'

sys.exit(1)

else:

print SSH negotiation sucessful

event.clear()

t.auth_password(username=username, 
password=password,event=event)

if not t.is_authenticated():

print not authenticated

output:

SSH negotiation successful

not authenticated

Tarun

Waterstone Capital Management

2 Carlson Parkway, Suite 260

Plymouth, MN 55447

Direct: 952-697-4123

Cell:612-205-2587
 Disclaimer This e-mail and any attachments is confidential and 
intended
solely for the use of the individual(s) to whom it is 
addressed. Any views
or opinions presented are solely those of the author and do not 
necessarily
represent those of Waterstone Capital Management, L.P and 
affiliates. If you
are not the intended recipient, be advised that you have 
received this
e-mail in error and that any use, dissemination, printing, 
forwarding or
copying of this email is strictly prohibited. Please contact 
the sender if
you have received this e-mail in error. You should also be 
aware that
e-mails are susceptible to interference and you should not 
assume that the
contents of this e-mail originated from the sender above or 
that they have
been accurately reproduced in their original form. Waterstone 
Capital
Management, L.P. and affiliates accepts no responsibility for 
information,
or errors or omissions in this e-mail or use or misuse thereof. 
If in doubt,
please verify the authenticity with the sender.
--
   http://mail.python.org/mailman/listinfo/python-list

   You are missing an event.wait() after t.auth_password.
   Also, why are you passing this magic value 15 to event.wait() ? 
   That
   parameter is passed to class _Verbose to indicate if debug 
   messages
   should be displayed or not, so typical values would be 0/1 or
   False/True.

   --
   -- Guilherme H. Polo Goncalves

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

 --
 -- Guilherme H. Polo Goncalves

ok here is the problem... I don't know what is the correct way... The
only demos i have from the paramiko library use a hostkeyfile. since i
don't have that i thought i would use the get_remote_key to get the
key and then connect it using the code in the demo.. But clearly
nothing is working...I should not HAVE to use the key since i should
be able to authenticate using the password...

Can you please suggest the right way to go ?

   You don't need to use key to authenticate using username and password,
   indeed. And you don't. Your first email was almost correct, you just
   needed to add event.wait() after t.auth_password. It worked here after
   doing that change. You can check out my version

Killing worker threads

2008-01-06 Thread tarun
Hello All,

Can anyone help me with a simple code through which the main thread can kill
the worker thread it started.

Thanks  Regards,
Tarun Devnani
-- 
http://mail.python.org/mailman/listinfo/python-list

GUI builder tool

2007-11-29 Thread tarun
Hi All,

Please help me in selecting the best tool for developing wxPython GUIs. I'm
preparing a tool that has explorer,editor and log window using wxPython..

I've heard some namely wxGlade,Boa,etc.. Which one would be the best.
Thanks in Advance

Regards,
Tarun
-- 
http://mail.python.org/mailman/listinfo/python-list

Fwd: Frame/Dialog with Tabs

2007-11-28 Thread tarun
 Hello,

Can anyone help with a *sample wxpython code* that can create a frame/dailog
with tabs.
Something similar in the attachment.

Thanks  Regards,
Tarun
attachment: Sample Frame.JPG-- 
http://mail.python.org/mailman/listinfo/python-list

Creation of multiple threads

2007-11-22 Thread tarun
Hello All,

I got the following example from
*http://wiki.wxpython.org/LongRunningTasks*http://wiki.wxpython.org/LongRunningTasks
This example shows how a worker thread can be created from the main GUI and
the main GUI is notified when the worker thread has done its work..

But my requirement is:
I want to have two worker threads and each one notifies the main thread. It
could be possible that when a worker thread is running, other might be
tirggerd.
1) Can I do with only one Worker thread class?
2) Can there be only one notification function for multiple threads.

 *CODE:*
**
import time
from threading import *
import wx

# Button definitions
ID_START = wx.NewId()
ID_STOP = wx.NewId()

# Define notification event for thread completion
EVT_RESULT_ID = wx.NewId()

def EVT_RESULT(win, func):
Define Result Event.
win.Connect(-1, -1, EVT_RESULT_ID, func)

class ResultEvent(wx.PyEvent):
Simple event to carry arbitrary result data.
def __init__(self, data):
Init Result Event.
wx.PyEvent.__init__(self)
self.SetEventType(EVT_RESULT_ID)
self.data = data

# Thread class that executes processing
class WorkerThread(Thread):
Worker Thread Class.
def __init__(self, notify_window):
Init Worker Thread Class.
Thread.__init__(self)
self._notify_window = notify_window
self._want_abort = 0
# This starts the thread running on creation, but you could
# also make the GUI thread responsible for calling this
self.start()

def run(self):
Run Worker Thread.
# This is the code executing in the new thread. Simulation of
# a long process (well, 10s here) as a simple loop - you will
# need to structure your processing so that you periodically
# peek at the abort variable
for i in range(10):
time.sleep(1)
if self._want_abort:
# Use a result of None to acknowledge the abort (of
# course you can use whatever you'd like or even
# a separate event type)
wx.PostEvent(self._notify_window, ResultEvent(None))
return
# Here's where the result would be returned (this is an
# example fixed result of the number 10, but it could be
# any Python object)
wx.PostEvent(self._notify_window, ResultEvent(10))

def abort(self):
abort worker thread.
# Method for use by main thread to signal an abort
self._want_abort = 1

# GUI Frame class that spins off the worker thread
class MainFrame(wx.Frame):
Class MainFrame.
def __init__(self, parent, id):
Create the MainFrame.
wx.Frame.__init__(self, parent, id, 'Thread Test')

# Dumb sample frame with two buttons
wx.Button(self, ID_START, 'Start', pos=(0,0))
wx.Button(self, ID_STOP, 'Stop', pos=(0,50))
self.status = wx.StaticText(self, -1, '', pos=(0,100))

self.Bind(wx.EVT_BUTTON, self.OnStart, id=ID_START)
self.Bind(wx.EVT_BUTTON, self.OnStop, id=ID_STOP)

# Set up event handler for any worker thread results
EVT_RESULT(self,self.OnResult)

# And indicate we don't have a worker thread yet
self.worker = None

def OnStart(self, event):
Start Computation.
# Trigger the worker thread unless it's already busy
if not self.worker:
self.status.SetLabel('Starting computation')
self.worker = WorkerThread(self)

def OnStop(self, event):
Stop Computation.
# Flag the worker thread to stop if running
if self.worker:
self.status.SetLabel('Trying to abort computation')
self.worker.abort()

def OnResult(self, event):
Show Result status.
if event.data is None:
# Thread aborted (using our convention of None return)
self.status.SetLabel('Computation aborted')
else:
# Process results here
self.status.SetLabel('Computation Result: %s' % event.data)
# In either event, the worker is done
self.worker = None

class MainApp(wx.App):
Class Main App.
def OnInit(self):
Init Main App.
self.frame = MainFrame(None, -1)
self.frame.Show(True)
self.SetTopWindow(self.frame)
return True

if __name__ == '__main__':
app = MainApp(0)
app.MainLoop()

 Help would be appreciated.

Thanks in advance

Regards,
Tarun
-- 
http://mail.python.org/mailman/listinfo/python-list

Issue with reading and writing into .ini files using python

2007-11-21 Thread tarun
Hello,

I am using config approach as mentioned in the below link to read and write
into setup (.ini) files:
http://www.voidspace.org.uk/python/configobj.html

I've a key named 'SELECTED' in my .ini file.

Sometimes I get the following error on trying to read the .ini file:val
= dict.__getitem__(self, key)
KeyError: 'SELECTED'

Can anyone help.

Thanks in advance

Regards,
Tarun
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Issue with wxPython GUI

2007-11-13 Thread tarun
Hi Laszlo Nagy,

Thanks a lot.
But the issue over here is that how will the child thread acknowledge the
main thread that it has completed its task. For this I'll have to set some
flag in the child thread and poll for it in the main thread. This will
create a problem. Any alternatives??

Thanks  Regards,
Tarun


On 11/13/07, Laszlo Nagy [EMAIL PROTECTED] wrote:


 
  *New Problem: *I am opening and executing a script from the GUI. The
  script has a many log messages,
  which it posts on some shared memory. The GUI reads the messages from
  the shared memory,
  in the Idle loop. But the script is huge and so the logging is not
  run-time.
  Rather this happens only after the script has executed. Moreover, the
  GUI becomes
  un-responsive till the script has completely executed.
 
 This is (probably) because you are running your script in your main
 thread. While the main thread of the application is running, your
 windowing system cannot process message queues. Since the updating of a
 text control uses window messages, it has no chance to process them. I
 recommend that you run your script in a separate (terminateable?)
 thread, send your messages into a Queue instance, and load messages from
 that queue in your main thread.
 
  Do you have any suggestions for this?
 Well, if you do not want to create more threads, it migth work if you
 call this periodically from your main thread (but I did not try this):


  wxApp::Dispatch

 *virtual void* *Dispatch*()

 Dispatches the next event in the windowing system event queue.

 This can be used for programming event loops, e.g.

 while (app.Pending())
Dispatch();



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

Re: Issue with wxPython GUI

2007-11-13 Thread tarun
Thanks a lot Laszlo Nagy,

I used the following and it worked.

import time
from threading import *
import wx

# Button definitions
ID_START = wx.NewId()
ID_STOP = wx.NewId()

# Define notification event for thread completion
EVT_RESULT_ID = wx.NewId()

def EVT_RESULT(win, func):
Define Result Event.
win.Connect(-1, -1, EVT_RESULT_ID, func)

class ResultEvent(wx.PyEvent):
Simple event to carry arbitrary result data.
def __init__(self, data):
Init Result Event.
wx.PyEvent.__init__(self)
self.SetEventType(EVT_RESULT_ID)
self.data = data

# Thread class that executes processing
class WorkerThread(Thread):
Worker Thread Class.
def __init__(self, notify_window):
Init Worker Thread Class.
Thread.__init__(self)
self._notify_window = notify_window
self._want_abort = 0
# This starts the thread running on creation, but you could
# also make the GUI thread responsible for calling this
self.start()

def run(self):
Run Worker Thread.
# This is the code executing in the new thread. Simulation of
# a long process (well, 10s here) as a simple loop - you will
# need to structure your processing so that you periodically
# peek at the abort variable
for i in range(10):
time.sleep(1)
if self._want_abort:
# Use a result of None to acknowledge the abort (of
# course you can use whatever you'd like or even
# a separate event type)
wx.PostEvent(self._notify_window, ResultEvent(None))
return
# Here's where the result would be returned (this is an
# example fixed result of the number 10, but it could be
# any Python object)
wx.PostEvent(self._notify_window, ResultEvent(10))

def abort(self):
abort worker thread.
# Method for use by main thread to signal an abort
self._want_abort = 1

# GUI Frame class that spins off the worker thread
class MainFrame(wx.Frame):
Class MainFrame.
def __init__(self, parent, id):
Create the MainFrame.
wx.Frame.__init__(self, parent, id, 'Thread Test')

# Dumb sample frame with two buttons
wx.Button(self, ID_START, 'Start', pos=(0,0))
wx.Button(self, ID_STOP, 'Stop', pos=(0,50))
self.status = wx.StaticText(self, -1, '', pos=(0,100))

self.Bind(wx.EVT_BUTTON, self.OnStart, id=ID_START)
self.Bind(wx.EVT_BUTTON, self.OnStop, id=ID_STOP)

# Set up event handler for any worker thread results
EVT_RESULT(self,self.OnResult)

# And indicate we don't have a worker thread yet
self.worker = None

def OnStart(self, event):
Start Computation.
# Trigger the worker thread unless it's already busy
if not self.worker:
self.status.SetLabel('Starting computation')
self.worker = WorkerThread(self)

def OnStop(self, event):
Stop Computation.
# Flag the worker thread to stop if running
if self.worker:
self.status.SetLabel('Trying to abort computation')
self.worker.abort()

def OnResult(self, event):
Show Result status.
if event.data is None:
# Thread aborted (using our convention of None return)
self.status.SetLabel('Computation aborted')
else:
# Process results here
self.status.SetLabel('Computation Result: %s' % event.data)
# In either event, the worker is done
self.worker = None

class MainApp(wx.App):
Class Main App.
def OnInit(self):
Init Main App.
self.frame = MainFrame(None, -1)
self.frame.Show(True)
self.SetTopWindow(self.frame)
return True

if __name__ == '__main__':
app = MainApp(0)
app.MainLoop()

Thanks  Regards,
Tarun

On 11/13/07, Laszlo Nagy [EMAIL PROTECTED] wrote:

 tarun írta:
  Hi Laszlo Nagy,
 
  Thanks a lot.
  But the issue over here is that how will the child thread acknowledge
  the main thread that it has completed its task. For this I'll have to
  set some flag in the child thread and poll for it in the main thread.
  This will create a problem.
 What kind of problem, can you explain? Supposing your child (worker)
 thread created the output, I would do it this way (untested):

 class Child(threading.Thread):
def __init__(self,output):
   self.stop_requested = threading.Event()
   self.stopped = threading.Event()
   self.output = output
   

def run(self):
   try:
   while not self.stop_requested.isSet():
# put your algorithm here

# but check periodically if you need to abort the job.
if self.stop_requested.isSet():
   break
...
# when you have data, put into the output queue

Issue with wxPython GUI

2007-11-12 Thread tarun
Hi All,

I've a probelm and solution for it to build the preface. Below it is the new
problem I'm facing. Can someone help me out?

*Problem:* I've have created a GUI (using wxPython widgets) where in I've a
message log window (A TextCtrl window).
I've a router.dll that helps me putting in message onto a channel. In my
script that generates the GUI,
I want to continuously poll the channel and populate the messages from the
channel to the message log window.

For this I've  to put a while (1) loop, but when I do this, the GUI doesn't
come up. I see the GUI coming
when while(1) is removed. Is there any issue with usage of app.mainloop and
while(1) together.

*Solution: *I used:
self.Bind (wx. EVT_IDLE, self.OnIdle)

And in the OnIdle function, I check if the data is available on the channel.

Referred: http://wiki.wxpython.org/LongRunningTasks


*New Problem: *I am opening and executing a script from the GUI. The script
has a many log messages,
which it posts on some shared memory. The GUI reads the messages from the
shared memory,
in the Idle loop. But the script is huge and so the logging is not run-time.

Rather this happens only after the script has executed. Moreover, the GUI
becomes
un-responsive till the script has completely executed.
Do you have any suggestions for this?

Thanks  Regards,
Tarun
-- 
http://mail.python.org/mailman/listinfo/python-list

Use of while(1) with app.mainLoop of wxpython

2007-11-01 Thread tarun
Dear All,

I've have created a GUI (using wxPython widgets) where in I've a message log
window (A TextCtrl window). I've a router.dll that helps me putting in
message onto a channel. In my script that generates the GUI, I want to
continuously poll the channel and populate the messages from the channel to
the message log window.

For this I've  to put a while (1) loop, but when I do this, the GUI doesn't
come up. I see the GUI coming when while(1) is removed. Is there any issue
with usage of app.mainloop and while(1) together.

Quick help would be really appreciated.

Thanks  Regards,
Tarun
-- 
http://mail.python.org/mailman/listinfo/python-list

Error on FTP Upload .. No such file or directory

2007-05-17 Thread Tarun Kapoor

---
Code
--

remotepath = /incoming

f = FTP(host)
f.login(username,password)
f.cwd(remotepath)
localfile =C:\\test.txt
fd = open(localfile,'rb')
path,filename = os.path.split(localfile)
f.storbinary('STOR %s' % filename,fd)
fd.close()
f.quit()



Error

Traceback (most recent call last):
  File P:\Working\Python code\temp.py, line 21, in ?
uploadFile(C:\\test.txt)
  File P:\Working\Python code\temp.py, line 16, in uploadFile
f.storbinary('STOR %s' % filename,fd)
  File C:\Python23\lib\ftplib.py, line 415, in storbinary
conn = self.transfercmd(cmd)
  File C:\Python23\lib\ftplib.py, line 345, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
  File C:\Python23\lib\ftplib.py, line 327, in ntransfercmd
resp = self.sendcmd(cmd)
  File C:\Python23\lib\ftplib.py, line 241, in sendcmd
return self.getresp()
  File C:\Python23\lib\ftplib.py, line 214, in getresp
raise error_perm, resp
ftplib.error_perm: 553 test.txt: No such file or directory.

Disclaimer

This e-mail and any attachments is confidential and intended solely for the use 
of the individual(s) to whom it is addressed. Any views or opinions presented 
are solely those of the author and do not necessarily represent those of 
Waterstone Capital Management, L.P and affiliates. If you are not the intended 
recipient, be advised that you have received this e-mail in error and that any 
use, dissemination, printing, forwarding or copying of this email is strictly 
prohibited. Please contact the sender if you have received this e-mail in 
error. You should also be aware that e-mails are susceptible to interference 
and you should not assume that the contents of this e-mail originated from the 
sender above or that they have been accurately reproduced in their original 
form. Waterstone Capital Management, L.P. and affiliates accepts no 
responsibility for information, or errors or omissions in this e-mail or use or 
misuse thereof. If in doubt, please verify the authenticity with the!
  sender.


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


Error on FTP Upload .. No such file or directory

2007-05-17 Thread Tarun Kapoor
By the way...

test.txt does exist

Disclaimer

This e-mail and any attachments is confidential and intended solely for the use 
of the individual(s) to whom it is addressed. Any views or opinions presented 
are solely those of the author and do not necessarily represent those of 
Waterstone Capital Management, L.P and affiliates. If you are not the intended 
recipient, be advised that you have received this e-mail in error and that any 
use, dissemination, printing, forwarding or copying of this email is strictly 
prohibited. Please contact the sender if you have received this e-mail in 
error. You should also be aware that e-mails are susceptible to interference 
and you should not assume that the contents of this e-mail originated from the 
sender above or that they have been accurately reproduced in their original 
form. Waterstone Capital Management, L.P. and affiliates accepts no 
responsibility for information, or errors or omissions in this e-mail or use or 
misuse thereof. If in doubt, please verify the authenticity with the!
  sender.


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