Re: Application monitor

2005-11-09 Thread Daniel Crespo
Many thanks for your answers.

Respect Init, I need a cross platform solution. Most of times my system
will run in Win98 and XP (more on XP than 98)

Respect Twisted... Mmm... I already started with another networking
library (TCPServer and SimpleXMLRPCServer), and I wouldn't like to mix
things because I don't know so much about those libraries. I know that
Twisted can do what I already have. But replacing it can be a hard
task. So I would like to have a function like FindPID(exename) --> PID,
or something more generic that could tell me the PID of a running
program, and kill him in a certain moment.

Daniel

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


Make an exe file as a Windows Service

2005-11-09 Thread Daniel Crespo
Hi to all,

How can I install an exe file as a service through Python?

Thanks

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


Re: Application monitor

2005-11-09 Thread Daniel Crespo
Magnus Lycka wrote:
> You *could* use twisted.runner for process control even if you
> don't use twisted for your networking code. It does seem like
> a funny thing to do, but there's nothing stopping you from doing
> that. The example code in twisted.runner starts up a few shell
> scripts that die on their own accord, and make sure they get
> restarted, so it doesn't rely on twisted being used in the
> processes it controls.

Ok. I'll take a look. Thank you very much! :)

Daniel

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


Re: Addressing the last element of a list

2005-11-10 Thread Daniel Crespo
Hi

Proposition 1:
> data = [0, None, 2, 0]
> ref = data[-1]
> ref = 1
> assert data[-1] == 1

Logically, it doesn't work. Here you are assigning to ref a NEW value.
That won't replace the data[-1] value. It's out of logic this
proposition.

While this (proposition 2):
data = [0, None, 2, ["hello"]]
ref = data[-1]
ref.append("world")

does work, because you are assigning to ref THAT list ["hello"]. So, if
you have THAT list, and appends a value, THAT list will be modified.
ref is pointing to THAT object. So, I don't understand why you write
the first proposition, like if that can be a normal thinking of how to
do the second proposition :-S

Well, I hope that newcomers to Python don't confuse himselves :)

Daniel

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


Re: how to start a process and get it's pid?

2005-11-11 Thread Daniel Crespo
Hi

> >>> os.spawnl(os.P_NOWAIT, "c:/windows/notepad.exe")
> 1944

I don't get the correct PID.

When I do os.spawnl(os.P_NOWAIT, "c:/windows/notepad.exe")
I get 168 (for example), while in the tasklist appears notepad.exe with
the 2476 PID.

Why?

Thanks

Daniel

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


Re: how to start a process and get it's pid?

2005-11-11 Thread Daniel Crespo
> >>> import subprocess
> >>> p = subprocess.Popen("c:/windows/notepad.exe")
> >>> p.pid

> 1948

Yes, it works. But in my case, I need to run the program totally
separated from my main program. So, when I start a new program through
subprocess, it doesn't unlink. I mean, if I close my main app, so does
the launched program. With startfile() it does the job, but I then I
have to find what pid is through win32all module, etc.

it would be very good if I can use spawnl

Daniel

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


Is there a built-in method for transforming (1, None, "Hello!") to 1, None, "Hello!"?

2005-11-11 Thread Daniel Crespo
Is there a built-in method for transforming (1,None,"Hello!") to
1,None,"Hello!"?

Thanks

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


Re: how to start a process and get it's pid?

2005-11-11 Thread Daniel Crespo
> not sure, but the return value looks like a PID, so maybe you're seeing the
> PID for the cmd.exe instance used to run the program.  or something.

No. There wasn't a 196 PID for any of the processes.

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


How to remove the log-error of an exe file (generated by py2exe)?

2005-11-11 Thread Daniel Crespo
Hi to all,

I have an exe file generated by py2exe. It runs perfect, but in some
parts of my code I raise exceptions. When I close my exe file, and if
it had errors, then they writes down to a .txt file in the same
directory of the referred exe file. I would like to not to generate
this error. Is it a py2exe option in the setup file?

Thanks

Daniel

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


A way for launch an app monitor

2005-11-15 Thread Daniel Crespo
Hello,

I'm in the way for creating an application and its monitor. Yes, there
are 2 applications: The main app, and a monitor. The last one monitors
the main application for keeping it alive, and viceversa. But if I
close the main app, I want to close the monitor.

That is very easy under nt systems, but in 98 is a little more tricky
because of the problem with closing processes.

For example, I can't use the following code on a win98 machine:

def FindPID(exename):
"""
usage:
pid=FindPID("pythonw.exe")
print pid
"""
a = os.popen4('tasklist /FI "IMAGENAME eq '+exename+'"')
a[0].flush()
try:
info=a[1].readlines()[3].split()
except:
info=[exename,"NotFound"]
return info[1] #PID

because the "tasklist" command doesn't exist on win98. Also, I tried to
install the kill.exe and a dont-remember-dll (from the Win98 Resource
Kit), but it doesn't work.

So my solution (need help on this) is that I have been thinking on
letting the monitor listen for socket connection. Through this, the
main app can tell him to close when the main app closes correctly. Do
you think this is well thought? Any suggestions?

Daniel

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


A way for closing an app monitor

2005-11-15 Thread Daniel Crespo
Hello,

I'm in the way for creating an application and its monitor. Yes, there
are 2 applications: The main app, and a monitor. The last one monitors
the main application for keeping it alive, and viceversa. But if I
close the main app, I want to close the monitor.

That is very easy under nt systems, but in 98 is a little more tricky
because of the problem with closing processes.

For example, I can't use the following code on a win98 machine:

def FindPID(exename):
"""
usage:
pid=FindPID("pythonw.exe")
print pid
"""
a = os.popen4('tasklist /FI "IMAGENAME eq '+exename+'"')
a[0].flush()
try:
info=a[1].readlines()[3].split()
except:
info=[exename,"NotFound"]
return info[1] #PID

because the "tasklist" command doesn't exist on win98. Also, I tried to
install the kill.exe and a dont-remember-dll (from the Win98 Resource
Kit), but it doesn't work.

So my solution (need help on this) is that I have been thinking on
letting the monitor listen for socket connection. Through this, the
main app can tell him to close when the main app closes correctly. Do
you think this is well thought? Any suggestions?

Daniel

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


Re: A way for closing an app monitor

2005-11-17 Thread Daniel Crespo
Ok. Thanks for your answer :-)

I have implemented  this and works correctly.

Daniel

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


Re: GTK for windows and Linux

2005-11-18 Thread Daniel Crespo
I prefer wxPython www.wxpython.org

Daniel

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


the PHP ternary operator equivalent on Python

2005-11-18 Thread Daniel Crespo
Hi!

I would like to know how can I do the PHP ternary operator/statement
(... ? ... : ...) in Python...

I want to something like:

a = {'Huge': (quantity>90) ? True : False}

Any suggestions?

Thanks

Daniel

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


How to do "new_variable = (variable) ? True : False; " (php) on python?

2005-11-18 Thread Daniel Crespo
Hello to all,

How can I do

new_variable = (variable) ? True : False;

in Python in one line?

I want to do something like this:

dic = {'item1': (variable) ? True-part : False-part}

Any suggestions?

Daniel

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


Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Daniel Crespo
Oh... Well, thanks for that information.

I'll do this then:

def TernaryOperation(condition,true_part,false_part):
if condition:
return True-part
else:
return False-part

a = {'Huge': TernaryOperation(quantity>90,True,False)}

Thank you

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


Re: the PHP ternary operator equivalent on Python

2005-11-18 Thread Daniel Crespo
Hi Peter,

Expand your mind.

a = {'whatever': TernaryOperation(quantity>90,"It is very huge","The
value is correct")}

;-)

thanks for your advice anyway

Daniel

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


Re: the PHP ternary operator equivalent on Python

2005-11-23 Thread Daniel Crespo
> WHY WHY WHY the obsession with one-liners? What is wrong with the good old
> fashioned way?


> if cond:
>x = true_value
> else:
>x = false_value

Let me tell you something: I'm not a one-liner coder, but sometimes It
is necesary.
For example:
I need to translate data from a DataField to Another.

def Evaluate(condition,truepart,falsepart):
if condition:
return truepart
else:
return falsepart

dOldDataFields = {}
dNewDataFields = {}

dNewDataFields = {
'CODE': dOldDataFields['CODEDATA'],
'DATE': dOldDataFields['DATE'],
'CONTACT':  Evaluate(dOldDataFields['CONTACTTYPE']==2,
dOldDataFields['FIRSTCONTACT'], dOldDataFields['SECONDCONTACT'])
}

With this, I created a new dic very easy, saving in
dNewDataFields['CONTACT'] the value of dOldDataFields['FIRSTCONTACT']
or the value of dOldDataFields['SECONDCONTACT'] depending on
dOldDataFields['CONTACTTYPE']. How you do this in a practic way without
the use of one-line code? It is needed! You can't avoid it! Even using
a = [if_false_expr, if_true_expr][predicate] or a function, you'll
always have to use a one-line code (for this purpose, of course).

Daniel

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


Re: Tutorials for Python + PostgreSQL

2005-11-23 Thread Daniel Crespo
Hi

Use adodb for it. Also, adodb accepts mysql, mssql, oracle, access, ...

Anyway, It needs psycopg for accessing Postgres databases, but I
recommend to use adodb, specially if you plan to use conectivity with
other databases too, because the access to them is the same way. Of
course, there are some differences between databases, but I think adodb
can care about it :)

http://adodb.sourceforge.net/
http://stickpeople.com/projects/python/win-psycopg/

Daniel

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


allow_none=True in SimpleXMLRPCServer

2005-12-12 Thread Daniel Crespo
Hello,

Does anyone know which methods do I have to override for allowing Nones
to be accepted and sended from SimpleXMLRPCServer to the client?

Thanks

Daniel

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


Re: Still Loving Python

2005-12-14 Thread Daniel Crespo
Lawrence Oluyede wrote:

> ps. the customer wants Windows as a platform, we develop on Linux using
> PyGTK, postgre and sql server for some old data. This is the true power of
> cross-platform :)

PyGTK is crossplatform, that's true, but it looks very ugly under
Windows and don't know under MacOS (if it's supported). I couldn't find
the way for get it running with an atractive look & feel under Windows
after compiling it. Also, it needs the GTK+ Runtime Environment. I use
wxPython and it is very very very very good. It's not perfect, but IMO,
it is much better than PyGTK. PyGTK is good if you intend to develop
for Linux.

Daniel

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


How to get the local mac address?

2005-12-14 Thread Daniel Crespo
Hi, I tried:

import ctypes
import socket
import struct

def get_macaddress(host):
""" Returns the MAC address of a network host, requires >= WIN2K.
"""

# Check for api availability
try:
SendARP = ctypes.windll.Iphlpapi.SendARP
except:
raise NotImplementedError('Usage only on Windows 2000 and
above')

# Doesn't work with loopbacks, but let's try and help.
if host == '127.0.0.1' or host.lower() == 'localhost':
host = socket.gethostname()

# gethostbyname blocks, so use it wisely.
try:
inetaddr = ctypes.windll.wsock32.inet_addr(host)
if inetaddr in (0, -1):
raise Exception
except:
hostip = socket.gethostbyname(host)
inetaddr = ctypes.windll.wsock32.inet_addr(hostip)

buffer = ctypes.c_buffer(6)
addlen = ctypes.c_ulong(ctypes.sizeof(buffer))
if SendARP(inetaddr, 0, ctypes.byref(buffer), ctypes.byref(addlen))
!= 0:
raise WindowsError('Retreival of mac address(%s) - failed' %
host)

# Convert binary data into a string.
macaddr = ''
for intval in struct.unpack('BB', buffer):
if intval > 15:
replacestr = '0x'
else:
replacestr = 'x'
macaddr = ''.join([macaddr, hex(intval).replace(replacestr,
'')])

return macaddr.upper()

if __name__ == '__main__':
print 'Your mac address is %s' % get_macaddress('localhost')

It works perfect under W2K and above. But I would like to run it on
Win98 too. Any help?

Thanks

Daniel

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


Re: Difference between ActivePython and Python.org

2005-12-14 Thread Daniel Crespo
Good question, I have the same anxiety.

Thanks

Daniel

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


Re: Still Loving Python

2005-12-14 Thread Daniel Crespo
> So wxPython doesn't need a runtime? I don't think so.  wxPython for me
> sucks under Linux (built on gtk2) and I don't like its API at all. It
> seems a bit awkward to me. Anyway... what do you mean with "much better" ?

It's much better:
- Its portability is superior over PyGTK
- Its look & feel is superior over PyGTK (except in Linux)

Under windows, only needs some dlls (they are its runtime), and works
perfect. The same exe works on Win98, ME, 2000, XP. Of course that
there are some differences between these OSs.

I tried both a lot, and I stay with wxPython :)

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


Re: allow_none=True in SimpleXMLRPCServer

2005-12-14 Thread Daniel Crespo
Thank you very much! I will try it as soon as possible, and write you
back with my results.

Best regards

Daniel

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


Re: Still Loving Python

2005-12-14 Thread Daniel Crespo
By the way:

> Under windows, only needs some dlls

py2exe does this job :)

Daniel

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


Re: How to get the local mac address?

2005-12-14 Thread Daniel Crespo
Hi, Scott,

Thanks for your answer

>> Hi, I tried: ...
>> # Convert binary data into a string.
>> macaddr = ''
>> for intval in struct.unpack('BB', buffer):
>> if intval > 15:
>> replacestr = '0x'
>> else:
>> replacestr = 'x'
>> macaddr = ''.join([macaddr, hex(intval).replace(replacestr, '')])
>
>
>Replace the above by:
>   return '%02X' * 6 % struct.unpack('BB', buffer)

Replace all the above? I mean all this:

 # Convert binary data into a string.
 macaddr = ''
 for intval in struct.unpack('BB', buffer):
 if intval > 15:
 replacestr = '0x'
 else:
 replacestr = 'x'
 macaddr = ''.join([macaddr, hex(intval).replace(replacestr,
'')])

?

>(doesn't help with win98, though)

Sorry, but I don't understand... I would like it to get running on
Win98. I know I have to change some code here, but don't know what :(

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


Re: How to get the local mac address?

2005-12-19 Thread Daniel Crespo
> I was looking on how to get MAC address universally (Windows and Linux) and
> found one package that is doing that and more...

> http://libdnet.sourceforge.net/

Thank you for the info too :)

Daniel

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


Re: allow_none=True in SimpleXMLRPCServer

2005-12-20 Thread Daniel Crespo
Hi Dody!

It works perfect! Now, I want the SimpleXMLRPCServer.py not to be on
the same directory, but in my /lib directory. I tried it, but it seems
that the module loads from python24/ first. How can I change this?

Thank you!

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


A weird problem (adodb + mysql)

2006-01-05 Thread Daniel Crespo
Hi to all,

I'm using adodb for accessing mysql and postgres. My problem relies on
the mysql access.

Sometimes, when I try to execute a query (using ExecTrans method
below), I get this error:

'NoneType' object has no attribute 'cursor'

Maybe this error ocurrs not in my code, but in the mysql module. Does
anyone had had this problem?

Thanks.

The following is my DB connection class.

class DB:
def __init__(self, host=None, user=None, password=None,
database=None):
self.host =
[host,variables.IP_DB][isinstance(host,(types.NoneType))]
self.user =
[user,variables.USER][isinstance(user,(types.NoneType))]
self.password =
[password,variables.PASSWORD][isinstance(password,(types.NoneType))]
self.database =
[database,variables.DATABASE][isinstance(database,(types.NoneType))]

self.bActive= True
self.bConnected = False

def OpenDB(self):

success = False
if self.bActive:
try:
self.conn = adodb.NewADOConnection('mysql')
if not self.conn:
Log.log("Can't connecto to DB-Mysql")
success = False
else :
#Create the connection
ret = self.conn.Connect(self.host, self.user,
self.password, self.database)
if ret:
Log.log("DB-Mysql connection stablished")
success = True
except:
success = False
pass
else:
print "DB connection disabled"
self.bConnected = success
return success

def Exec(self,query,simple=False):
resultado = list()

#Open a DB connection
if self.OpenDB():
Log.log("Executing Query: " + str(query))
cursor = self.conn.Execute(query)
if cursor:
while not cursor.EOF:
if not simple:
resultado.append(cursor.GetRowAssoc())
cursor.MoveNext()
else :
resultado.append(cursor.FetchRow())
#Close Cursor
cursor.Close()
else:
resultado = None
self.CloseDB()
else:
resultado = None
return resultado

def ExecTrans(self, lQueries):

success = False
if self.OpenDB():
print "Executing Querys: " + str(lQueries)

#Begin Transaction
self.conn.BeginTrans()

#Execute each query in lQueries
for query in lQueries:
self.conn.Execute(query)
if self.conn._errno != 0 :
success = False
break;
else:
success = True

#End of transaction
if success:
self.conn.CommitTrans()
else:
self.conn.RollbackTrans()

#Closing DB
self.CloseDB()
return success

def TestConnection(self):
if self.OpenDB():
self.CloseDB()
return True
return False

def CloseDB(self):
if self.conn.IsConnected() :
self.conn.Close()
return

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


An app without GUI

2006-01-10 Thread Daniel Crespo
Hello to all,

I have to build a server app without GUI. This app must be an xml-rpc
server, so it has to be up all the time. I would control it through the
xml-rpc port from a web interface using php, sending parameters to
defined xml-rpc functions for running certain processes, like viewing
current connections, restart it or shutting it down, for example.

Actually, I have it implemented with wxPython. The GUI controls when
the xml-rpc server is running, so when I close the GUI, so does the
server and all the dependent threads.

I want to do something like the MainLoop(), but without GUI. I can sit
down and build all this stuff, but I would like to know if someone had
passed through this. Any tips?

Thanks

Daniel

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


Secure XMLRPC Server / PEM Files

2006-09-11 Thread Daniel Crespo
Hello everybody,

I'm trying to implement a secure xmlrpc server with basis on
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496786 recipe.
The thing that I'm concerned about is how can I get/create rapidly the
.pem files (the key and cert).

Any help?

Thanks

Daniel

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


Re: Secure XMLRPC Server / PEM Files

2006-09-11 Thread Daniel Crespo

Laszlo Nagy wrote:
> >
> >
> > If you have OpenSSL installed, you can do the following:
> >
> > 1. Create a new directory and place the two attached files in it
> > (openssl.cnf and generate.sh)
> > 2. Run  "chmod +x gen_cert.sh ; ./gen_cert.sh  yourdomain.com"
> I meant generate.sh instead of gen_cert.sh.
>
> Under windows it won't work. But you can easily convert generate.sh into
> generate.bat. :-)
>
>   Laszlo

I'm on Windows...
I'm also trying to get OpenSSL installed, but I need compilers and all
that stuff. Before getting involved in that, do you know of a faster
way to have it installed?

Thanks

Daniel

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


Re: Secure XMLRPC Server / PEM Files

2006-09-11 Thread Daniel Crespo
Hi Laszlo,

I have read that. It's the wrapper for the usage of OpenSSL, so I have
to install it. I have downloaded the Borland C++ compiler, and I'm
doing so right now, but I'm not getting good results yet.

I tried to import OpenSSL, it seems to work.

Now, I want to try the code I submited earlier, but I need the .pem
files. You told me to change generate.sh to generate.bat. How can I do
that?

Many thanks,

Daniel


Laszlo Nagy wrote:
> Daniel Crespo írta:
> > Laszlo Nagy wrote:
> >
> >>> If you have OpenSSL installed, you can do the following:
> >>>
> >>> 1. Create a new directory and place the two attached files in it
> >>> (openssl.cnf and generate.sh)
> >>> 2. Run  "chmod +x gen_cert.sh ; ./gen_cert.sh  yourdomain.com"
> >>>
> >> I meant generate.sh instead of gen_cert.sh.
> >>
> >> Under windows it won't work. But you can easily convert generate.sh into
> >> generate.bat. :-)
> >>
> >>   Laszlo
> >>
> >
> > I'm on Windows...
> > I'm also trying to get OpenSSL installed, but I need compilers and all
> > that stuff. Before getting involved in that, do you know of a faster
> > way to have it installed?
> >
> Yes. Read the recipe once more. Especially, the first document string in
> that program. ;-)
>
> """For windows users: 
> http://webcleaner.sourceforge.net/pyOpenSSL-0.6.win32-py2.4.exe""";
>
> (You will also need the openssl binaries for windows, but they are very easy 
> to find.)
> 
> 
>Laszlo

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


Re: Secure XMLRPC Server / PEM Files

2006-09-12 Thread Daniel Crespo
Hi Laszlo,

> Try this (untested):
>
> openssl req -config openssl.cnf -new -out my-server.csr
> openssl rsa -in privkey.pem -out my-server.key

Here's what I tried:

C:\OpenSSL\bin>openssl req -config openssl.cnf -new -out my-server.csr
Loading 'screen' into random state - done
Generating a 1024 bit RSA private key
.++
..++
writing new private key to 'privkey.pem'
Enter PEM pass phrase: PASSWORD
Verifying - Enter PEM pass phrase: PASSWORD
-
You are about to be asked to enter information that will be
incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a
DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:DF
Locality Name (eg, city) []:CITY
Organization Name (eg, company) [Internet Widgits Pty Ltd]:COMPANY
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:PASSWORD
An optional company name []:COMPANY

C:\OpenSSL\bin>openssl rsa -in privkey.pem -out my-server.key
Enter pass phrase for privkey.pem: PASSWORD
unable to load Private Key
3688:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad
decrypt:.\
crypto\evp\evp_enc.c:461:
3688:error:0906A065:PEM routines:PEM_do_header:bad
decrypt:.\crypto\pem\pem_lib.
c:425:

Any help?

Thanks in advance

Daniel

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


Resolved: Secure XMLRPC Server / PEM Files

2006-09-12 Thread Daniel Crespo
www.openssl.org. If you are using Windows, go
to http://www.slproweb.com/products/Win32OpenSSL.html and install the
binary.

2. In order to have our required .pem files, put the following in a
batch file (.sh or .bat) and run it from the directory where openssl is
(unless it is set as an environment variable):

openssl req -config openssl.cnf -new -out my-server.csr
openssl rsa -in privkey.pem -out my-server.key
openssl x509 -in my-server.csr -out my-server.cert -req -signkey
my-server.key -days 1500
openssl x509 -in my-server.cert -out my-server.der.crt -outform DER

mv my-server.csr $1.csr
mv my-server.cert $1.cert.pem
mv my-server.key $1.key.pem
mv my-server.der.crt $1.der.crt

rm privkey.pem
rm -f .rnd

(for .bat, just ignore the last line and use "move" instead of "mv",
"del" instead of "rm" and "yourdomain.com" instead of "$1")

It will generate 4 files. Take the two with .pem extension, and put it
on the same directory as the SecureXMLRPCServer code.

3. In order for get running the code, install pyOpenSSL available at
http://pyopenssl.sourceforge.net/. For Windows you may prefer
http://webcleaner.sourceforge.net/pyOpenSSL-0.6.win32-py2.4.exe

That's it.

Special thanks to Laszlo Nagy

Enjoy!

Daniel Crespo

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


Print a PDF transparently

2006-02-17 Thread Daniel Crespo
Hi to all,

I want to print a PDF right from my python app transparently. With
"transparently" I mean that no matter what program handles the print
petition, the user shouldn't be noticed about it.

For example, when I want to print a PDF, Adobe Acrobat fires and keep
opened. This is what I don't want to happen (and I thing there are a
lot of people who want this too). So I just want to send the PDF to the
right handler and print it. That's all.

I've seen some things like Adobe's Postscript driver that can read a
PDF, or Ghostscript, but I still don't know how to use it.

Any help for printing a PDF transparently?

Thank you

Daniel

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


Re: Print a PDF transparently

2006-02-17 Thread Daniel Crespo
Hi, Thanks for all the answers.

My main purpose is to print on Windows systems (98,2000,XP) and permit
to print pages of 1/3 of a letter height, and make the printer to stop
at that point (in dot matrix printers). When I have a PDF with that
paper size and send it to print from Acrobat, it prints and stops
perfect (in Win98, I have to create a custom form consisting of that
paper size). The problem is that PDF files have to be handled by
external applications, or non-free drivers.

Based on all this, I have been investigating about postscript files. I
realize that printers do handle this language, so I think if I have a
.ps file and send it directly to the printer, it should do the job,
right? (this is certainly a question) If the answer is True, no matter
in what platform I am, if I send the same .ps to the printer, it should
print the same result.

And if all of these is true, then, my problem reduces to generate the
.ps file.

Comments please

Daniel

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


Re: Print a PDF transparently

2006-02-17 Thread Daniel Crespo
> Adobe has a Windows PostScript driver for free; but that still
> leaves you out... It works as a "printer" but you still have to run the
> normal application to print /to/ it -- and that is what you say you
> don't want! http://www.adobe.com/support/downloads/detail.jsp?ftpID=1500

Yes, I've seen it, but that's it: another program that I have to
install, which I want to avoid.

I'd be happy if I just do "printer.Print(file.pdf/.ps)" and walá, the
printing just starts (in 98,2000,XP... sounds like a dream), without
having another window opened. If it opens, but then closes, it's
perfect too. I have tried installing Ghostscript, and having a .ps when
I order that file to print, it does the job. The thing here is that I
have to install it.

All this has to be easilly installed (with InnoSetup, for example),
because I have to install it on 70 offices. So I can't leave it to
another installation process. All of these offices have a dot matrix
printers Epson LX-300, which has PostScript level 3 built-in.

Where can I find how to send a .ps directly to the printer?

Daniel

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


Re: Print a PDF transparently

2006-02-20 Thread Daniel Crespo
> Have you seen this?
> http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html
> In particular, the section on using win32print directly.

Yes, I have. The problems is that an external program is launched for
handling the file and print it. In the case of PDF, acrobat is
launched. In the case of PS, Ghostview is launched. When printing a
PDF, acrobat keeps alive, so the user has to close it manually. On the
other hand, Ghostview is opened, prints the file and closes
automatically. The last one is which I find the best for me, until now,
(because the Ghostview closes automatically). If I decide to go this
way, my problem then is to transform a pdf to ps, or generate a ps
directly.

For further information on what I want, please, refer to my first two
posts in this topic.

Any other help?

Thank you very much

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


Re: Print a PDF transparently

2006-02-20 Thread Daniel Crespo
> Have you seen this?
> http://tgolden.sc.sabren.com/python/win32_how_do_i/print.html
> In particular, the section on using win32print directly.

Yes, I have. The problems is that an external program is launched for
handling the file and print it. In the case of PDF, acrobat is
launched. In the case of PS, Ghostview is launched. When printing a
PDF, acrobat keeps alive, so the user has to close it manually. On the
other hand, Ghostview is opened, prints the file and closes
automatically. The last one is which I find the best for me, until now,
(because the Ghostview closes automatically). If I decide to go this
way, my problem then is to transform a pdf to ps, or generate a ps
directly.

For further information on what I want, please, refer to my first two
posts in this topic.

Any other help?

Thank you very much

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


Re: Print a PDF transparently

2006-02-21 Thread Daniel Crespo
Thank you very much Roger Upole and Tim Golden for your posts...

I found an exe that can print a pdf file (using Acrobat Reader) on any
windows printer right from the command line. It opens Acrobat, order it
to print the pdf file at a certain printer and then closes Acrobat. The
exe is a c-compiled program from someone that supplied it in a forum.

That works almost perfect for me. The only thing now is that when I'm
printing a PDF in dot matrix printers, the output is very ugly, and I
don't know how to improve it.

I think I will go for printing in plain text. The only problem with it
is that one have to depend on the physical printer configuration.

Daniel

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


PDF on dot matrix printers

2006-02-21 Thread Daniel Crespo
Hi to all,

Does anyone know about how to make a dot matrix printer print a PDF
file with the quality of a Microsoft Word printing?

When I print from Microsoft Word, the output is perfect for the kind of
printer. But, from a PDF file, the characters are distortionated in an
uniform way. With "uniform" I mean that no matter where I put the
characters in the page, the character "e" always will be smaller than
an "a". So, when seeing the output page, and trying to read what it has
written, you realize that the characters have different heights... It
could be a matter of resolution, obviously not in the printer, but in
the PDF. So I'm wondering if there are some tasks that I could do for
accomplish it.

Thanks for reading

Daniel

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