I want to split a string so that I always return everything BEFORE the LAST
underscore
HELLO_.lst # should return HELLO
HELLO_GOODBYE_.ls # should return HELLO_GOODBYE
I have tried with rsplit but cannot get it to work.
Any help appreciated
--
http://mail.python.org/m
For testing purposes I want my code to raise a socket "connection reset by
peer" error, so that I can test how I handle it, but I am not sure how to raise
the error.
Any advice appreciated
--
http://mail.python.org/mailman/listinfo/python-list
I have a sockets client that is connecting to a printer and occassionally
getting the error "104 Connection reset by peer"
I have not been able to diagnose what is causing this. Is there any additional
traceing I can do(either within my python code or on the network) to establish
what is causin
I have a socket application that is connecting to a HP printer via port 9100.
Occassionally I get a "Connection reset by peer" error which I am trapping and
exiting the script with an error message.
That works Ok, the issue I have is that the next time I run the script I get
"Connection refused"
Replies to questions :
1. Does the printer accept connections again after some time?
Yes, bit seems to vary how long that takes
2. Does the printer accept connections if you close and re-open the
Python interpreter?
Not after a Connection reset error. The script exits after trapping the
"Con
Well, I certainly suspect the customers network connection to the printer which
is over a WAN across half of Europe, but proving that is the problem is another
matter.
I can replicate a "Connection reset by peer" error on own printer by pulling
the network cable out of the printer. And again I
I am looking to monitor print jobs on linux via python.
pycups looks a possibility, but I cannot find any useful tutorial, examples of
how to use it.
Can anyone help?
--
http://mail.python.org/mailman/listinfo/python-list
I am writing an application to send data to a printer port(9100) and then
recieve PJL responses back on that port. Because of the way PJL works I have to
do both in the same process(script).
At the moment I do not start to read responses until the data has been sent to
the printer. However it s
I have threaded python script that uses sockets to monitor network ports.
I want to ensure that the socket is closed cleanly in all circumstances. This
includes if the script is killed or interupted in some other way.
As I understand it signal only works in the main thread, so how can I trap
in
I am trying to match a string that containing the "<" and ">" characters, using
the string contains function, but it never seems to find the lines containing
the string
e.g if mystring.contains("") :
Do I need to escape the characters...and if so how?
--
http://mail.python.org/mailman/listinf
On Tuesday, 9 October 2012 15:19:33 UTC+1, Agon Hajdari wrote:
> On 10/09/2012 04:02 PM, loial wrote: > I am trying to match a string that
> containing the "<" and ">" characters, using the string contains function,
> but it never seems to find the
How can I find the full path of the lowest level directory in a directory
structure?
If there is more than one directory at the lowest level, the first one found
will be enough.
Any help appreciated
--
http://mail.python.org/mailman/listinfo/python-list
I am parseing a file to extract data, but am seeing the file being updated even
though I never explicitly write to the file. It is possible that another
process is doing this at some later time, but I just want to check that opening
the file as follows and ignoring a record would not result in t
Thanks for confirming my sanity
On Monday, 28 January 2013 11:57:43 UTC, Chris Angelico wrote:
> On Mon, Jan 28, 2013 at 10:47 PM, loial wrote: > I am
> parseing a file to extract data, but am seeing the file being updated even
> though I never explicitly write to the file. It
I am trying to write a python script to read data from a printer port
using python sockets, but it seems I am locking up the port.
Is there a way to ensure that I do not block the port to other
applications?
My knowledge of python sockets is minimal, so any help would be
appreciated.
--
http://m
OS is Red hat enterprise linux 5.5 and python version is 2.6
On Feb 2, 4:34 pm, Dennis Lee Bieber wrote:
> On Thu, 2 Feb 2012 05:53:22 -0800 (PST), loial
> wrote:
>
> >I am trying to write a python script to read data from a printer port
> >using python sockets, but it
Unfortunately using jpython or json are not options at the moment
--
http://mail.python.org/mailman/listinfo/python-list
I am trying to hardlink all files in a directory structure using
os.link.
This works fine for files, but the directory also contains sub-
directories (which themselves contain files and sub-directories).
However I do not think it is possible to hard link directories ?
So presumably I would need t
When I correctly trap an IOError a spurious u' appears in the file
path in the exception message :
The path used in the code is correct i.e. /home/myfile
But the error message says :
[Errno 2] No such file or directory: u'/home/myfile'
I am simply doing
except IOError, e:
print s
Does python have an equivalent of the java Timezone object?
I need to be able to get offsets for timezones (only U.S. time zones
at the moment)
--
http://mail.python.org/mailman/listinfo/python-list
("EST");
long remoteOffset = tz2.getOffset(date.getTime());
Any help appreciated
On May 23, 11:48 am, Daniel Kluev wrote:
> On Mon, May 23, 2011 at 9:32 PM, loial wrote:
> > Does python have an equivalent of the java Timezone object?
>
> > I need to be able
I need to pass some sort of array or hashmap from Java and read the
data in a python script (which will be called by the java class). Is
there any neater way to do this other than just passing strings?
--
http://mail.python.org/mailman/listinfo/python-list
I am getting a permission issue with the following code
targetdirectory = '/data/upload'
self.ZIPFileName = targetDirectory + os.sep + "MY.ZIP"
zf = zipfile.ZipFile(self.ZIPFileName, mode='w')
[Errno 13] Permission denied: '/data/upload/MY.ZIP'
The t
I am getting a permission issue with the following code
targetDirectory = '/data/upload'
self.ZIPFileName = targetDirectory + os.sep + "MY.ZIP"
zf = zipfile.ZipFile(self.ZIPFileName, mode='w')
[Errno 13] Permission denied: '/data/upload/MY.ZIP'
The
I am trying to run lpr from python 2.7.10 on windows
However I always get the error
'C:/windows/system32/lpr.exe ' is not recognized as an internal or external
command,
operable program or batch file.
Even though typing the same at the command prompt works OK
Any ideas?
I am using subprocess
As I said, the lpr command works fine from the command prompt but not from
python.
Everything is 64-bit (windows server 2012).
--
https://mail.python.org/mailman/listinfo/python-list
I get the same issue if I just specify "lpr" rather than a full path, i.e. it
works from the command prompt(with forward slashes), but not from python
--
https://mail.python.org/mailman/listinfo/python-list
Nothing seems to work.
Even doing
import os
os.system("lpr")
still returns
'lpr' is not recognized as an internal or external command,operable program or
batch file.
Even though I can run lpr fine from the command prompt
--
https://mail.python.org/mailman/listinfo/python-list
I am reposting this question in a simpler form.
I can run lpr from the command prompt but not from python
os.system("notepad") works
os.system("lpr") does not work. Basically it says lpr is not a known program or
executable
Why can I run lpr from the windows command prompt but not from python(2
I finally found the solution here :
http://www.tomshardware.co.uk/forum/240019-44-error-windows
Copied lpr.exe, lprhelp.dll, and lprmonui.dll from the System32 folder to the
sysWOW64 folder
Thanks for all your efforts
--
https://mail.python.org/mailman/listinfo/python-list
016, at 10:15, loial wrote:
> > I am reposting this question in a simpler form.
> >
> > I can run lpr from the command prompt but not from python
> >
> > os.system("notepad") works
> > os.system("lpr") does not work. Basically it says lpr is n
I have a python 2.7.10 script which is being run under a windows service on
windows 2012 server .
The python script uses smtplib to send an email.
It works fine when the windows service is run as a local user, but not when the
windows service is configured to run as Local System account. I get n
I am suddenly having a problem with importing a module from a zip file in
Python 2.4.1
What has been working for years suddenly has an error :
zipimport.ZipImportError: can't find module 'mymodule'
PYTHONPATH is correct, it points to the zip file containing mymodule
N.B. the python script(unch
I want to add a path to sys.path based upon a variable
Can I do that?
Hardcodeing the path works fine, but I want to set it based upon a variable.
I know I can set PYTHONPATH, but just wondering if I can add a directory on the
fly to sys.path using a variable
--
https://mail.python.org/ma
Ok, that works fine with the apth hard coded, but I want to do something like
the code below. i.e I am trying to dynamically add a path that is relative to
the path of the current executing python script.
In this case the import fails.
import sys
import os
from os.path import *
scriptpath=os.p
Idiot that I am...I was not calling the script with the full path !
Thanks for your help
--
https://mail.python.org/mailman/listinfo/python-list
I am migrating a python script from Red hat linux REL 6.6 to AIX 7.1
I am using python 2.7.10
On AIX I the ror
zipimport.ZipImportError: can't decompress data; zlib not available
Any ideas how to get this to work on AIX?
--
https://mail.python.org/mailman/listinfo/python-list
What is the best package to use with python 2.6 to access Web services. Is it
ZSI?
Can anyone recommend a good tutorial, preferably with a sandbox web service?
--
https://mail.python.org/mailman/listinfo/python-list
On Linux we use
#!/usr/bin/env python
At the start of scripts to ensure that the python executable used is the one
defined in the PATH variable, rather than hardcoding a path to the python
executable.
What is the equivalent functionality in Windows?
--
https://mail.python.org/mailman/listinf
On Friday, February 20, 2015 at 2:54:26 PM UTC, Ian wrote:
> On Feb 20, 2015 7:46 AM, "loial" wrote:
>
> >
>
> > On Linux we use
>
> > #!/usr/bin/env python
>
> >
>
> > At the start of scripts to ensure that the python executable used
Is there a quick way to concatenate all the values in a list into a string,
except the first value?
I want this to work with variable length lists.
All values in list will be strings.
Any help appreciated
--
https://mail.python.org/mailman/listinfo/python-list
Many thanks for those you chose to help me out. Problem solved.
--
https://mail.python.org/mailman/listinfo/python-list
How do I read a binary file, find/identify a character string and replace it
with another character string and write out to another file?
Its the finding of the string in a binary file that I am not clear on.
Any help appreciated
--
https://mail.python.org/mailman/listinfo/python-list
Thanks Emile.
Unfortunately I have to use python 2.6 for this
On Wednesday, 5 March 2014 00:13:00 UTC, emile wrote:
> On 03/04/2014 02:44 PM, Chris Angelico wrote:
>
> > On Wed, Mar 5, 2014 at 12:18 AM, Peter Otten <__pete...@web.de> wrote:
>
> >> loial wrote:
I am having issues using the netrc package for users where the password is
blank.
It works fine for users with password is not blank and is spacified in the
.netrc
I am not sure if this is an issue with the .netrc file or my use of the .netrc
package.
.netrc file looks like :
machine myserve
Anyone out there got any examples of calling the UK Royal Mail Mailmark web
service from python?
--
https://mail.python.org/mailman/listinfo/python-list
I need to execute an external shell script via subprocess on Linux.
One of the parameters needs to be passed inside double quotes
But the double quotes do not appear to be passed to the script
I am using :
myscript = '/home/john/myscript'
commandline = myscript + ' ' + '\"Hello\"'
process = s
Yep, that did the trick...cheers
On Tuesday, September 8, 2015 at 12:04:05 PM UTC+1, loial wrote:
> I need to execute an external shell script via subprocess on Linux.
>
> One of the parameters needs to be passed inside double quotes
>
> But the double quotes do not appear to b
I need to modify the LIBPATH environment variable when running a process via
subprocess, but otherwise retain the existing environment.
Whats the best way to do that?
--
https://mail.python.org/mailman/listinfo/python-list
I want to monitor printers for events such as the completion of printing.
If the printer initiates an SNMP trap event when the job has finished printing,
how can I capture this?
Presumably I need some sort of deamon to listen for these trap messages. I have
looked at pySNMP but am not sure if t
If I read a file using a for loop, as follows, is the file left open if I
execute a break in the for loop?
for line in open(myFile).readlines():
if something:
break
--
https://mail.python.org/mailman/listinfo/python-list
I want to call a child process to run a shell script and wait for that script
to finish. Will the code below wait for the script to finish? If not then how
do I make it wait?
Any help appreciated.
import subprocess
command = "/home/john/myscript"
process = subprocess.Popen(command,
stdin=su
I need help installing paramiko on ActiveState python on AIX 5
I am new to python so need info on how to download and install
paramiko
AIX box does not have internet connection so presume cannot use
ez_setup.py?
Can anyone help?
--
http://mail.python.org/mailman/listinfo/python-list
Is there anyway in pythn to check whether a file is being used/written
to by another process, e.g like the fuser command?
--
http://mail.python.org/mailman/listinfo/python-list
I'ma a newbie python user and would like clarification on variable
naming conventions.
What is the difference between
self.myvariable
self._myvariable
self.__myvariable
and when should I use each of them?
--
http://mail.python.org/mailman/listinfo/python-list
I am having problems with os.rename on AIX
The source file definately exists and the target file does not.
However the rename always generates an OSerror exception. I can do
the rename via a mv statement at the AIX command line with no problem.
How can I get more info what the cause of the OSE
I need to store a list of variable names in a dictionary or list. I
then later need to retrieve the names of the variables and get the
values from the named variables. The named variables will already have
been created and given a value.
I hope thats clear!!!
How can I do this?
--
http://mail.p
I am running on an AIX system with time zone set to BST
If I run the following, I get the GMT time, i.e an hour less than the
correct time.
How can I get the correct time
now = time()
timeProcessed = strftime("%H:%M",gmtime(now))
--
http://mail.python.org/mailman/listinfo/pyth
Pointal <[EMAIL PROTECTED]> wrote:
> Cameron Laird wrote:
> > In article <[EMAIL PROTECTED]>,
> > Laurent Pointal <[EMAIL PROTECTED]> wrote:
> >>loial a ?it :
> >>> I need to store a list ofvariablenames in a dictionary or list. I
> >>&
I have been asked to install a python application on AIX 5.3 that runs
OK on Windows
I have installed Python 4.2.2 from python.org and pyXML form
sourceforge.
However when I run the application I get the following error :
class xml.sax._exceptions.SAXReaderNotAvailable
Do I need to set some Pyth
I am new to python and am converting an awk script to python
I need to store some data in an array/table of some form
keyvalue1, value1, value2, value3
keyvalue2, value1,value2, value3
keyvalue3, value1,value2,value3
etc
I will later need to sort in keyvalue order and also need to be able
to che
OK, thanks for the replies
One other thing...I need to update the values since they are basically
totals that I am accumulating.
How do I update a specific value for a specific key?
--
http://mail.python.org/mailman/listinfo/python-list
The following code only returns the last row(22) added to the
machines dictionary.
presumably I need some additional syntax to add rows to the dictionary
rather than overwrite.
What do I need to add?
machinekey = "11"
machines = { machinekey:[1,0,0,0,0,0,0,0,0,0,0,0,0] }
machinekey = "2
machines[machinekey] = [0,1,0,0,0,0,0,0,0,0,0,0,0]
is what I needed...thanks
On 16 Apr, 15:07, Christoph Haas <[EMAIL PROTECTED]> wrote:
> On Mon, Apr 16, 2007 at 06:43:37AM -0700, loial wrote:
> > The following code only returns the last row(22) added to the
> >
The following code gives the error
d=sortedmachines[machine]
TypeError: list indices must be integers
What works for the unsorted dictionary does not work for the sorted
dictionary.
Can anyone help?
machinekey = "11"
machines = {}
machines[machinekey]=[1,0,0,0,0,0,0,0,0,0,0,0,0]
machinek
I am writing a file in python with writelines
f = open('/home/john/myfile',"w")
f.writelines("line1\n")
f.writelines("line2\n")
f.close()
But whenever I try to do anything with the file in python it finds no
data. I am trying ftp, copying the file...the resultant file is always
0 bytes, although
Is there any difference?
Does it matter which I use?
--
http://mail.python.org/mailman/listinfo/python-list
Trying to use ftplib.FTP.nlst() method to list the files in
a directory on a FTP server.
It works fine except when there are no files in the directory. Then it
gives the error
ftplib.error_perm: 550 No files found.
How can I handle this cleanly?
--
http://mail.python.org/mailman/listinfo/py
How can I delete hidden files on unix with python, i.e I want to do
equivalent of
rm .lock*
--
http://mail.python.org/mailman/listinfo/python-list
I am trying to learn about web services and how to interface with a
3rd party web service from python.
Can anyone point me at an idiots guide/tutorial for someone who is new
to web services?
--
http://mail.python.org/mailman/listinfo/python-list
Has anyone any experiencing with ssh between a python client and the
SSH Tectia server from SSH (ssh.com) ?
Does it work?
--
http://mail.python.org/mailman/listinfo/python-list
Anyone out there any experience of using python ssh modules to connect
to the Tetia SSH server from SSH (ssh.com)?
--
http://mail.python.org/mailman/listinfo/python-list
I want to connect via ssh from a python script on windows to an AIX
server running openSSH using rsa keys rather than a password.
Can anyone provide me with /point me at a simple tutuorial on the
steps I need to go though in terms of geneerating the key, installing
on the server and connecting in
Can anyone be a little more helpful than Tino?
I have generated the key file as follows on windows and ftp'd the
id_rsa.pub file to the .ssh directory on the server and renamed to
authorized_keys
import paramiko
key = paramiko.RSAKey.generate(2048)
key.write_private_key_file('Z:/id_rsa')
file
On 10 Feb, 17:08, "Martin P. Hellwig"
wrote:
> loial wrote:
> > Can anyone be a little more helpful than Tino?
>
>
> I'll do some freebie hints :-)
> What I would do is try first whether key authentication works at all,
> for example following a tutori
I have been given an old python application that calls ftplib in many
places to copy files to a remote server.
I have been given the task of cloneing this code so that ftp is not
used, but files are just copied locally in a scenerio where ftp is not
available. The code is not well structured which
Is there anyway, having been passed a file handle, to get the
filename?
I am assuming not, but thought I would ask
--
http://mail.python.org/mailman/listinfo/python-list
Is it possible to use sftp without a password from python?
--
http://mail.python.org/mailman/listinfo/python-list
On 8 Jan, 18:49, Mike Hjorleifsson wrote:
> On Jan 8, 10:39 am, loial wrote:
>
> > Is it possible to usesftpwithout a password from python?
>
> Yes you can use keys you preestablish between the server and client so
> you dont need passwords, i do this on all my serv
A shell script is passing parameters to my python script in the
following format
-PARAM1 12345 -PARAM2 67890
Can I parse these with optparse ? If so how?
I can't seem to get it to work. It seems to expect --PARAM1 and --
PARAM2
--
http://mail.python.org/mailman/listinfo/python-list
I have a requirement to compare 2 text files and write to a 3rd file
only those lines that appear in the 2nd file but not in the 1st file.
Rather than re-invent the wheel I am wondering if anyone has written
anything already?
--
http://mail.python.org/mailman/listinfo/python-list
Given a section like
[Data]
value1
value2
value3
Can ConfigParser be easily used to put the values in a dictionary? If
so, how?
--
http://mail.python.org/mailman/listinfo/python-list
On 20 Aug, 13:49, alex23 <[EMAIL PROTECTED]> wrote:
> On Aug 20, 5:34 pm, loial <[EMAIL PROTECTED]> wrote:
>
> > Given a section like
>
> > [Data]
> > value1
> > value2
> > value3
>
> > Can ConfigParser be easily used to put the valu
I have a problem with a ssh connection in python
I get the error
'NoneType' object has no attribute 'exec_command'
I am thinking that maybe the ssh connection is timeing out.
Since I have no control over the configuration of the ssh server(which
is AIX 5.23), is there anything I can do in pytho
<>
def command ( self , command ) :
""" process requested command through ssh """
print command
if not self._connected :
return False , "No SSH connection available"
try :
stdin , stdout , stderr =
self._ssh.exec_command( command )
In unix shell script I can do the following to get the status and
values returned by a unix command
OUTPUT=`some unix command`
STATUS=$?
if [ $STATUS -ne 0 ]
then
exit 1
else
set $OUTPUT
VAL1=$1
VAL2=$2
VAL3=$3
fi
How can I achieve the same in python?
I know how to run it via the os.sy
I want to do a select from...for update in python, update the selected
row and then commit;
However cannot seem to get it to work...the update statement seems to
be waiting because the row is locked. Presumably oracle thinks the
update is another transaction.
How can I get this to work? What stat
Anyone got any experience of send PJL commands to a printer using
Python on Unix?
--
http://mail.python.org/mailman/listinfo/python-list
Thanks for responding..
First question...how do I send it to the printer? Printer would be
on the network.
--
http://mail.python.org/mailman/listinfo/python-list
Thank you. I was able to send the following PJL to the printer and it
worked.
@PJL STMSG DISPLAY = "Hello from John"
Do you have any experience handling PJL responses from the
printer?...What I really want to do is get PJL information back from
the printer and read it in python(or some other Unix
What is the easiest way to send a text file to a networked printer
from a python script running on windows?
--
http://mail.python.org/mailman/listinfo/python-list
I have a requirement to kick off a shell script from a python script
without waiting for it to complete. I am not bothered about any return
code from the script.
What is the easiest way to do this. I have looked at popen but cannot
see how to do it.
--
http://mail.python.org/mailman/listinfo/p
In a unix shell script I can do something like this to look in a
directory and get the name of a file or files into a variable :
MYFILE=`ls /home/mydir/JOHN*.xml`
Can I do this in one line in python?
--
http://mail.python.org/mailman/listinfo/python-list
On 3 Aug, 11:31, Alex Willmer wrote:
> On Aug 3, 11:21 am, loial wrote:
>
> > In a unix shell script I can do something like this to look in a
> > directory and get the name of a file or files into a variable :
>
> > MYFILE=`ls /home/mydir/JOHN*.xml`
>
> >
I am am trying to run the following command via subprocess
lpr -P printqueue filetoprint
I cannot seem to get it to work and return stderr
I think the issue is how to specify the arguments
I am trying
subprocess.Popen(['lpr -P' ,'laserlpr','/etc/hosts'], shell=False)
but get error :
Tracebac
ess.PIPE, stderr=subprocess.PIPE)
print process.communicate()
On 4 Aug, 12:08, Peter Otten <__pete...@web.de> wrote:
> loial wrote:
> > I am am trying to run the following command via subprocess
>
> > lpr -P printqueue filetoprint
>
> > I cannot seem to get i
I need to read a large amount of data that is being returned in
standard output by a shell script I am calling.
(I think the script should really be writing to a file but I have no
control over that)
Currently I have the following code. It seeems to work, however I
suspect this may not work with
Ok, thats great. Thanks for the very elegant solution(s)
On 6 Aug, 13:44, Nobody wrote:
> On Fri, 06 Aug 2010 02:06:29 -0700, loial wrote:
> > I need to read a large amount of data that is being returned in
> > standard output by a shell script I am calling.
>
> > (I
Is there a quick way to retrieve data from an xml file in python 2.4,
rather than read the whole file?
--
http://mail.python.org/mailman/listinfo/python-list
I want to enable my end users to be able to schedule a task(actually
running another python or shell script). Rather than scheduling it
directly in cron, are there any python modules I could use?
--
http://mail.python.org/mailman/listinfo/python-list
1 - 100 of 103 matches
Mail list logo