SimpleXMLRPCServer interruptable?

2007-12-05 Thread Bret
I'm coming back to Python after an absence and it's surprising how
many things I've forgotten since wandering (against my will) into Java
land.

Anyway, I have a need for a way to make SimpleXMLRPCServer
interruptable.  Basically, I have a main server that, in response to
certain RPC calls, creates additional servers on different ports.  I
then need to be able to shut these additional servers down.

I've got something like this in the __init__ of the class which
contains the spawned servers:

def __init__(self, host, port):
:
:
server = SimpleXMLRPCServer((host, port))
:
: Bunch of server.register_function calls
:
def serverWrapper():
try:
while True:
server.handle_request()
except:
pass

One of the methods that I register is:

def shutdown(self):
raise "Quitting time"

Through watching logs and such I can see that the shutdown() method is
getting called, but the loop isn't getting broken.  I've done
something like this before in a previous job (so I don't have my
source in front of me, more's the pity) and am hoping someone can
chime in with a good idea.

Thanks in advance!


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


Re: SimpleXMLRPCServer interruptable?

2007-12-05 Thread Bret
I just tried changing this so that I now have a threading.Event()
called self.done, which is set within the body of the shutdown()
method.  The serverWrapper loop now looks like this:

def serverWrapper():
while True:
server.handle_request()
if self.done.isSet():
break

This works, but only if I follow the shutdown() rpc call a few seconds
later with ... something else to cause handle_request() to complete
again.  Obviously, not quite the right approach


On Dec 5, 2:00 pm, Bret <[EMAIL PROTECTED]> wrote:
> I'm coming back to Python after an absence and it's surprising how
> many things I've forgotten since wandering (against my will) into Java
> land.
>
> Anyway, I have a need for a way to make SimpleXMLRPCServer
> interruptable.  Basically, I have a main server that, in response to
> certain RPC calls, creates additional servers on different ports.  I
> then need to be able to shut these additional servers down.
>
> I've got something like this in the __init__ of the class which
> contains the spawned servers:
>
> def __init__(self, host, port):
> :
> :
> server = SimpleXMLRPCServer((host, port))
> :
> : Bunch of server.register_function calls
> :
> def serverWrapper():
> try:
> while True:
> server.handle_request()
> except:
> pass
>
> One of the methods that I register is:
>
> def shutdown(self):
> raise "Quitting time"
>
> Through watching logs and such I can see that the shutdown() method is
> getting called, but the loop isn't getting broken.  I've done
> something like this before in a previous job (so I don't have my
> source in front of me, more's the pity) and am hoping someone can
> chime in with a good idea.
>
> Thanks in advance!
>
> Bret Wortman
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: SimpleXMLRPCServer interruptable?

2007-12-06 Thread Bret
On Dec 5, 10:00 pm, Edward Kozlowski <[EMAIL PROTECTED]> wrote:
> On Dec 5, 10:19 pm, Edward Kozlowski <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Dec 5, 6:22 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> > > En Wed, 05 Dec 2007 18:20:35 -0300, Bret <[EMAIL PROTECTED]> escribió:
>
> > > > I just tried changing this so that I now have a threading.Event()
> > > > called self.done, which is set within the body of the shutdown()
> > > > method.  The serverWrapper loop now looks like this:
>
> > > > def serverWrapper():
> > > > while True:
> > > > server.handle_request()
> > > > if self.done.isSet():
> > > > break
>
> > > > This works, but only if I follow the shutdown() rpc call a few seconds
> > > > later with ... something else to cause handle_request() to complete
> > > > again.  Obviously, not quite the right approach
>
> > > You could try setting a reasonable timeout on the listening socket; I
> > > would override the server_bind method, calling self.socket.settimeout(xxx)
> > > before calling the inherited method. I've never actually done it with a
> > > SimpleXMLRPCServer, but *should* work. Don't use a very small timeout,
> > > because it affects *all* subsequent operations.
>
> > > --
> > > Gabriel Genellina
>
> > Try this:
>
> > def __init__(self, host, port):
> > self.done = False
> > server = SimpleXMLRPCServer((host, port))
> > :
> > : Bunch of server.register_function calls
> > :
> > def serverWrapper():
> > try:
> > while not self.done:
> > server.handle_request()
> > except:
> > pass
>
> > Your shutdown method becomes:
>
> > def shutdown(self):
> > self.done = True
>
> > HTH
>
> > -Edward Kozlowski
>
> Sorry about the first post, I shot from the hip and had to make a few
> more modifications to make it 'working' code.  The example below works
> fine for me.
>
> import SimpleXMLRPCServer
>
> class myServer:
> def __init__(self, host, port):
> self.done = False
> self.server = SimpleXMLRPCServer.SimpleXMLRPCServer((host,
> port))
>
> def shutdown(self):
> self.done = True
> return 0
>
> def getName(self):
> return "Hey, I'm Ed"
>
> def serverWrapper(self):
> self.server.register_function(self.getName)
> self.server.register_function(self.shutdown)
> try:
> while not self.done:
> self.server.handle_request()
> except:
> pass
>
> if __name__ == "__main__":
> myServer('localhost', 6058).serverWrapper()
>
> >>> s.getName()
> "Hey, I'm Ed"
> >>> s.shutdown()
>
> 0

Thanks to all!  I'm now keeping a file of my own snippets in hardcopy
so I won't lose them next time I change jobs.  :-)


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


Re: SimpleXMLRPCServer interruptable?

2007-12-06 Thread Bret
On Dec 6, 7:04 am, Bret <[EMAIL PROTECTED]> wrote:
> On Dec 5, 10:00 pm, Edward Kozlowski <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Dec 5, 10:19 pm, Edward Kozlowski <[EMAIL PROTECTED]> wrote:
>
> > > On Dec 5, 6:22 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> > > > En Wed, 05 Dec 2007 18:20:35 -0300, Bret <[EMAIL PROTECTED]> escribió:
>
> > > > > I just tried changing this so that I now have a threading.Event()
> > > > > called self.done, which is set within the body of the shutdown()
> > > > > method.  The serverWrapper loop now looks like this:
>
> > > > > def serverWrapper():
> > > > > while True:
> > > > > server.handle_request()
> > > > > if self.done.isSet():
> > > > > break
>
> > > > > This works, but only if I follow the shutdown() rpc call a few seconds
> > > > > later with ... something else to cause handle_request() to complete
> > > > > again.  Obviously, not quite the right approach
>
> > > > You could try setting a reasonable timeout on the listening socket; I
> > > > would override the server_bind method, calling 
> > > > self.socket.settimeout(xxx)
> > > > before calling the inherited method. I've never actually done it with a
> > > > SimpleXMLRPCServer, but *should* work. Don't use a very small timeout,
> > > > because it affects *all* subsequent operations.
>
> > > > --
> > > > Gabriel Genellina
>
> > > Try this:
>
> > > def __init__(self, host, port):
> > > self.done = False
> > > server = SimpleXMLRPCServer((host, port))
> > > :
> > > : Bunch of server.register_function calls
> > > :
> > > def serverWrapper():
> > > try:
> > > while not self.done:
> > > server.handle_request()
> > > except:
> > > pass
>
> > > Your shutdown method becomes:
>
> > > def shutdown(self):
> > > self.done = True
>
> > > HTH
>
> > > -Edward Kozlowski
>
> > Sorry about the first post, I shot from the hip and had to make a few
> > more modifications to make it 'working' code.  The example below works
> > fine for me.
>
> > import SimpleXMLRPCServer
>
> > class myServer:
> > def __init__(self, host, port):
> > self.done = False
> > self.server = SimpleXMLRPCServer.SimpleXMLRPCServer((host,
> > port))
>
> > def shutdown(self):
> > self.done = True
> > return 0
>
> > def getName(self):
> > return "Hey, I'm Ed"
>
> > def serverWrapper(self):
> > self.server.register_function(self.getName)
> > self.server.register_function(self.shutdown)
> > try:
> > while not self.done:
> > self.server.handle_request()
> > except:
> > pass
>
> > if __name__ == "__main__":
> > myServer('localhost', 6058).serverWrapper()
>
> > >>> s.getName()
> > "Hey, I'm Ed"
> > >>> s.shutdown()
>
> > 0
>
> Thanks to all!  I'm now keeping a file of my own snippets in hardcopy
> so I won't lose them next time I change jobs.  :-)
>
> Bret

Oops, this actually misses part of the problem -- I need to construct
this server programmatically, so imbedding the call to start the
server in the "if __name__" construct doesn't work.  If I start it
within the __init__, then the object that's creating it gets stuck
waiting for it to finish, which it never will.  I need this to be
autonomous, which is why I was trying to do the start of the server in
a separate thread, but that doesn't seem to work either (that's what's
causing my process to need the second call; the thread completes the
loop and enters the next handle_request() call before the event or
boolean gets set).

Basically, I need a way for one server to start other autonomous
servers without waiting on them, and still retain the ability to shut
them down when their work is done.

Back to the keyboard.  ;-)


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


Re: SimpleXMLRPCServer interruptable?

2007-12-06 Thread Bret
On Dec 6, 7:04 am, Bret <[EMAIL PROTECTED]> wrote:
> On Dec 5, 10:00 pm, Edward Kozlowski <[EMAIL PROTECTED]> wrote:
>
>
>
> > On Dec 5, 10:19 pm, Edward Kozlowski <[EMAIL PROTECTED]> wrote:
>
> > > On Dec 5, 6:22 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
>
> > > > En Wed, 05 Dec 2007 18:20:35 -0300, Bret <[EMAIL PROTECTED]> escribió:
>
> > > > > I just tried changing this so that I now have a threading.Event()
> > > > > called self.done, which is set within the body of the shutdown()
> > > > > method.  The serverWrapper loop now looks like this:
>
> > > > > def serverWrapper():
> > > > > while True:
> > > > > server.handle_request()
> > > > > if self.done.isSet():
> > > > > break
>
> > > > > This works, but only if I follow the shutdown() rpc call a few seconds
> > > > > later with ... something else to cause handle_request() to complete
> > > > > again.  Obviously, not quite the right approach
>
> > > > You could try setting a reasonable timeout on the listening socket; I
> > > > would override the server_bind method, calling 
> > > > self.socket.settimeout(xxx)
> > > > before calling the inherited method. I've never actually done it with a
> > > > SimpleXMLRPCServer, but *should* work. Don't use a very small timeout,
> > > > because it affects *all* subsequent operations.
>
> > > > --
> > > > Gabriel Genellina
>
> > > Try this:
>
> > > def __init__(self, host, port):
> > > self.done = False
> > > server = SimpleXMLRPCServer((host, port))
> > > :
> > > : Bunch of server.register_function calls
> > > :
> > > def serverWrapper():
> > > try:
> > > while not self.done:
> > > server.handle_request()
> > > except:
> > > pass
>
> > > Your shutdown method becomes:
>
> > > def shutdown(self):
> > > self.done = True
>
> > > HTH
>
> > > -Edward Kozlowski
>
> > Sorry about the first post, I shot from the hip and had to make a few
> > more modifications to make it 'working' code.  The example below works
> > fine for me.
>
> > import SimpleXMLRPCServer
>
> > class myServer:
> > def __init__(self, host, port):
> > self.done = False
> > self.server = SimpleXMLRPCServer.SimpleXMLRPCServer((host,
> > port))
>
> > def shutdown(self):
> > self.done = True
> > return 0
>
> > def getName(self):
> > return "Hey, I'm Ed"
>
> > def serverWrapper(self):
> > self.server.register_function(self.getName)
> > self.server.register_function(self.shutdown)
> > try:
> > while not self.done:
> > self.server.handle_request()
> > except:
> > pass
>
> > if __name__ == "__main__":
> > myServer('localhost', 6058).serverWrapper()
>
> > >>> s.getName()
> > "Hey, I'm Ed"
> > >>> s.shutdown()
>
> > 0
>
> Thanks to all!  I'm now keeping a file of my own snippets in hardcopy
> so I won't lose them next time I change jobs.  :-)
>
> Bret

For completeness, what I ended up doing is this:

server = SimpleXMLRPCServer((host, port))
server.socket.settimeout(0.1)

ServerWrapper became:

def ServerWrapper():
while True:
try:
server.handle_request()
if self.done.isSet():
break
except timeout:
pass

And that seems to do the trick!  Giving the socket a timeout allows me
to check the Event more frequently and catch the change within a
reasonable time.

Thanks again, Ed and Gabriel.


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


Re: SimpleXMLRPCServer interruptable?

2007-12-10 Thread Bret
On Dec 6, 7:43 pm, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote:
> En Thu, 06 Dec 2007 13:11:09 -0300, Bret <[EMAIL PROTECTED]> escribió:
>
>
>
> > For completeness, what I ended up doing is this:
>
> > server = SimpleXMLRPCServer((host, port))
> > server.socket.settimeout(0.1)
>
> > ServerWrapper became:
>
> > def ServerWrapper():
> > while True:
> > try:
> > server.handle_request()
> > if self.done.isSet():
> > break
> > except timeout:
> > pass
>
> > And that seems to do the trick!  Giving the socket a timeout allows me
> > to check the Event more frequently and catch the change within a
> > reasonable time.
>
> Remember that the timeout applies to *all* socket operations; what if the
> XML request requires more than 0.1s to read?
> If handling large requests is more important than the delay at shutdown
> time, consider raising that value.
>
> --
> Gabriel Genellina

Good point.  Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Source formatting fixer?

2007-12-10 Thread Bret
Does anyone know of a package that can be used to "fix" bad formatting
in Python code?  I don't mean actual errors, just instances where
someone did things that violate the style guide and render the code
harder to read.

If nothing exists, I'll start working on some sed scripts or something
to add spaces back in but I'm hoping someone out there has already
done something like this.

Thanks!


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


Re: Source formatting fixer?

2007-12-14 Thread Bret
The thing is, I'm not so much trying to fix indentation issues as
spacing problems that affect readability but not program structure.
All the indentation is fine, this is more trying to change things
like:

if ((one==two)and(three==four)):
a=b+42
c=Classname (a,b)
print "Class %s created"%c.__name__

None of the above is wrong, it's just painfully ugly and given
Python's natural beauty, it seems really wrong all the same


Bret

On Dec 11, 3:26 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
>
> Python already comes with a reindenter, see Tools\scripts\reindent.py
> If you want to transform y= f (   x- 3 ) into y = f(x - 3) try PythonTidy
> (search this same group for a link)
>
> --
> Gabriel Genellina

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


A global or module-level variable?

2008-01-22 Thread Bret
This has to be easier than I'm making it

I've got a module, remote.py, which contains a number of classes, all
of whom open a port for communication.  I'd like to have a way to
coordinate these port numbers akin to this:

So I have this in the __init__.py file for a package called cstore:

nextport=42000

def getNextPort():
nextport += 1
return nextport

:
Then, in the class where I wish to use this (in cstore.remote.py):
:


class Spam():

def __init__(self, **kwargs):
self._port = cstore.getNextPort()

I can't seem to make this work, though.  As given here, I get an
"UnboundLocalError:local variable 'nextport' referenced before
assignment".  When I try prefixing the names inside __init__.py with
"cstore.", I get an error that the global name "cstore" is not
defined.

I've been looking at this long enough that my eyes are blurring.  Any
ideas?

BTW, the driving force here is that I'm going to need to wrap this in
some thread synchronization.  For now, though, I'm just trying to get
the basics working.

Thanks!


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


Re: A global or module-level variable?

2008-01-23 Thread Bret
On Jan 22, 1:00 pm, Paul Rubin  wrote:

> If you have to do it that way, use:

Is there a better way?  A more Pythonic way?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A global or module-level variable?

2008-01-24 Thread Bret
On Jan 23, 2:27 pm, "Gabriel Genellina" <[EMAIL PROTECTED]>
wrote:
> En Wed, 23 Jan 2008 11:58:05 -0200, Bret <[EMAIL PROTECTED]> escribió:
>
> > On Jan 22, 1:00 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote:
>
> >> If you have to do it that way, use:
>
> > Is there a better way?  A more Pythonic way?
>
> It's simple, clear and works fine, why make it more complicated?
> Unless you have additional requirements, like a multithreaded program.
>
> --
> Gabriel Genellina

Ultimately, it will be multithreaded -- and I had intended to wrap the
access to the global member in a lock to ensure only one thread could
get a value at any point.  It might also become multiprocess (ugh!)
and so might need to live in its own SocketServer some day.  But for
now, I agree.  Simple is good.  I just wanted to be sure I wasn't
oversimplifying, you know?

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


ActiveState/O'Reilly Launch New and Improved Code Share Site (Python)

2010-02-19 Thread Bret
ActiveState launched today the new code.activestate.com with code
recipes for dynamic languages such as Python, Perl and Tcl and web
development. This site is great recipe sharing site for all Python,
Perl and Tcl developers.

O'Reilly will be use recipes from the site for its next Python cook
book.

Bit.ly link to the blog announcement:
http://bit.ly/b1Wkdm
-- 
http://mail.python.org/mailman/listinfo/python-list


csv.reader has trouble with comma inside quotes inside brackets

2009-06-09 Thread Bret
i have a csv file like so:
row1,field1,[field2][text in field2 "quote, quote"],field3,field
row2,field1,[field2]text in field2 "quote, quote",field3,field

using csv.reader to read the file, the first row is broken into two
fields:
[field2][text in field2 "quote
and
 quote"

while the second row is read correctly with:
[field2]text in field2 "quote, quote"
being one field.

any ideas how to make csv.reader work correctly for the first case?
the problem is the comma inside the quote inside the brackets, ie:
[","]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: csv.reader has trouble with comma inside quotes inside brackets

2009-06-09 Thread Bret
Thanks John,

I didn't realize that the quotes were supposed to surround the entire
field.  I ended up making a quick script to replace comma's outside
quotes with tabs.  I was just trying to clean this crazy "csv" file to
import into msyql.

thanks again,

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


Re: pysqlite smart search

2009-02-23 Thread Bret Fledderjohn
2009/2/23 klia 

>
>
>
> klia wrote:
> >
> >  Hey guys;
> >
> > I am trying to develop a tiny program using python to search inside
> sqlite
> > database with file extension is .db in which the program will ask users
> to
> > enter their search query and base on that it will retrieve the results
> But
> >
> > I need the program to have some smartness in search mechanism in which
> the
> > program will guess that the user is looking for these key words in the
> > database.
> >
> > so far i came up with this but the search ain't smart, i have to write
> the
> > full key word in order to retrieve specific information.
> >
> > from pysqlite2 import dbapi2 as sqlite3
> >
> > connection = sqlite3.connect('Photos.db')
> > memoryConnection = sqlite3.connect(':memory:')
> > cursor = connection.cursor()
> > prompt = 'Enter your search query?\n'
> > keyword = raw_input(prompt)
> > if cursor.execute('SELECT * FROM photos WHERE Tag LIKE ?',[keyword]):
> > print cursor.fetchall()
> > else:
> > cursor.execute('SELECT * FROM photos WHERE Date LIKE ?', [keyword])
> > print cursor.fetchall()
> >
> > Any ideas and
> > thanks in advance
> > Reply
> >
>
> thank you man, it worked perfectly but one more thing;
>
> when i print rows it retrieves the whole rows of info which i don't need, i
> need just to retrieve the name of the photo.
> so how am i gonna do that?


It depends on the structure of your table, but you're going to have to
change the following lines:
>if cursor.execute('SELECT * FROM photos WHERE Tag LIKE ?',[keyword]):
>cursor.execute('SELECT * FROM photos WHERE Date LIKE ?', [keyword])
* indicates all fields in the selected records, so you need to
change the * to the field that contains the name of the photo.  For example:
if cursor.execute('SELECT name FROM photos WHERE Tag LIKE ?',[keyword]):

--
> View this message in context:
> http://www.nabble.com/pysqlite-smart-search-tp22157116p22161119.html
> Sent from the Python - python-list mailing list archive at Nabble.com.
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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


Re: Queries

2009-02-26 Thread Bret Fledderjohn
2009/2/26 Steve Holden 

> Murray wrote:
> [top-posting corrected]
>
> > -Original Message-
> > From: Gary Herron [mailto:gher...@islandtraining.com]
> > Sent: Thursday, February 26, 2009 1:46 AM
> > To: mmcclaf; python-list@python.org
> > Subject: Re: Queries
> >
> > mmcclaf wrote:
> >> I have to make  some queries for 4 tables I have. The following
> >> relations are:
> >>
> >> Classes(class, type, country, numGuns, bore, displacement)
> >> Ships (name, class, launched)
> >> Battles (name, date)
> >> Outcomes (ship, battle, result)
> >>
> >> The three queries I'm stuck on are the following:
> >>
> >> 1. Find the classes that have only one ship as a member of that class
> >> (not all ships are listed in the Ship table)
>
> Investigate a GROUP BY solution that selects groups having a count of 1.

DISTINCT may be a simpler solution.

>
>
> >> 2. Find the countries that had both battleships and battlecruisers
> >> (those fall under type in Classes)
>
> Look at EXISTS for one possible solutions.
>
> >> 3. Find those ships that "lived to fight another day"; they were
> >> damaged in one battle, but later fought in another.
> >>
> >From your model description I don't even see where the position and
> attitude of each ship is stored, so I don't think I can give you any
> help at all with this one.
>
> >> The best way for me to understand would be relational algebra for each
> >> of the statements.
> >>
> >
> >
> > Sounds like a homework assignment.Good luck with it.
> >
> > It is, however I was able to get the first 8 done, I am struggling with
> > these 3 particular ones. I have to make an SQL file based off of it,
> so this
> > seems to be a blockage in my works.
> >
> Good luck with the homework. Remember to acknowledge the help you've had
> from this list (particularly your earlier issues: here you just have
> hints).
>
> regards
>  Steve
> --
> Steve Holden+1 571 484 6266   +1 800 494 3119
> Holden Web LLC  http://www.holdenweb.com/
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



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


Re: Run a python script as an exe and run a new process from it

2009-02-26 Thread Bret Fledderjohn
2009/2/26 venutaurus...@gmail.com 

> On Feb 26, 7:00 pm, "venutaurus...@gmail.com"
>  wrote:
> > On Feb 26, 6:10 pm, Tim Wintle  wrote:
> >
> >
> >
> > > On Thu, 2009-02-26 at 04:55 -0800, venutaurus...@gmail.com wrote:
> > > > Hello all,
> > > >I've a strange requirement where I need to run a python
> > > > script just as we run an exe (by double clicking through windows
> > > > explorer or by typing the script name at command prompt).
> >
> > > I don't know how windows deals with this part>  In that
> > > > process I should be able to execute another python script in such a
> > > > way that, the second script should continue running but the main one
> > > > should terminate without effecting the second one.
> >
> > > standard daemon behavior I'd have thought
> >
> > > This shows how you would do it (with lots of comments). Assume this
> > > should work on Windows.
> >
> > >http://code.activestate.com/recipes/278731/
> >
> > > note the two child threads to prevent zombies - may not be needed on
> > > windows but good to use them anyway.
> >
> > Thanks for the reply,
> >Being a newbie to python, I am finding it difficult to
> > understand the logic even after thorough reading of comments. Is there
> > any simpler way where I can just run a python script from the main
> > script and exit without disturbing the second one(This will end based
> > on some other constraints which can be handled). Or can some one throw
> > some light on where should I run the function os.system(" python
> > script2.py") from the main one.
> >
> > Thank you,
> > venu
>
> Adding to the above.. I've to do it in Windows platform and what I can
> see from the illustration (/dev/null) etc. they are for Unix
> Environment.


For making a script executable try this link
http://www.python.org/doc/faq/windows/#how-do-i-make-python-scripts-executable



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


Re: What do you think of ShowMeDo

2009-04-29 Thread Bret Fledderjohn
2009/4/29 David Robinow 

> On Wed, Apr 29, 2009 at 9:29 AM,   wrote:
> ...
> > To reiterate, I responded to this thread because I think Ben's posting
> > gave an unfair impression of the site and i felt the need to address
> > some misconceptions. I am sorry you failed to find the videos, but
> > many tens of thousands are found every week and I really haven't heard
> > of anyone failing to find their way to the content. In this sense I
> > think you are exceptional.
> Count me as one who couldn't find his way. I'm not usually very
> sympathetic to whining about Gui's that aren't perfect, but this one
> is beyond my ability to traverse.
> I'd really like to view some of the content. I have no concern about
> the licensing; I have no intent to redistribute. Why do you make it so
> difficult?
> How about an ftp site with a directory of videos? That I could understand.


Not sure why navigation has been a problem, I was able to follow it.  A bit
too many choices to get to the same place in round about ways, but I was
able to navigate it.  This thread has piqued my interest, so having done no
real GUI programming in Python, I am going to try out Kyran's wxPython
tutorial.

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


Re: tough-to-explain Python

2009-07-07 Thread Bret Fledderjohn
I really enjoyed your boxes analogy, from a guy with a trucking background,
it makes a lot of sense!
-Bret


> ... The more I delve into OOP the more I liken an 'object' to a box. A box
> with a shipping manifest.
>
> There are big boxes,
> little boxes,
> squat boxes and so on.
>
> A box can contain corn flakes,
> bullets, raisins, rice, burlap, silk, motorcycle(s), soap and more.
>
> The manifest describes contents.
> The manifest is there but the description(s) change with content (type).
> The descriptions always use one or more of the basics like: color, count,
> dimension and so forth.
>
> Just like an OOP object.
>
> A box can contain things of all sorts, including references to the contents
> of other box(es). A box can even be a virtual of another (the global
> concept).  The return statement, in this context, means hauling the contents
> of the box (and/or its manifest) back to (wherever) and disposing of the
> current box (a local).
>
> Just like an OOP object.
>
>
> It is easier to visualize a box and it's use than a non described blob.
> Abstracts are never precise -  hence the evolution of the word.
>
>
> The one thing a teacher will always fail is the same as anyone else who
> tries to adequately describe a pretty sunset to a person born totally blind.
> No point(s) of reference.
>
>
>
> Time for me to sign off.  To all those that helped me when I needed it -
>
> I thank you very much.
>
> Food for thought: your watch (clock) does not tell time.
> The watch (clock) only mimics one movement of the earth.
> ie... 3 dimensions are still static, the 4th is movement.
>
>
> Steve


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


Create on Win and run on Win or Mac

2015-06-01 Thread Bret Edwards via Python-list

I would like to create a Python (stand-alone executable) program on a Windows 
machine and deploy the finished product on other Windows machines (of varying 
Windows OS versions) and 
also on Mac machines (of varying Mac OS versions.) The program would present a 
GUI that the user would interact with and would only have simple computations. 

I looks like I could do the creation work twice (once for Windows and once for 
Mac) and then also create separate install packages. However, I would like to 
only do the creation 
work once and do it on a Windows machine and then be able to deploy to either 
Win or Mac. I understand that will mean separate intstallation packages due to 
the different 
environments. 

Is this possible? I do not think that it is, but asking just to be sure.

If so, what tools do I use to do the packaging? Do I use py2app for the Mac?
Thanks,
Bret

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


Create Web app on Win and run on Win or Mac

2015-06-01 Thread Bret Edwards via Python-list
I took a look at Ren'Py as suggested by a reply to my previous post entitled 
"Create on Win and run on Win or Mac." Thanks for your suggestion. Ren'Py looks 
pretty amazing!

Not sure that is a good route since my primary reason for this endeavor is 
learning Python scripting (secondarily to create the game) and Ren'Py uses it's 
own scripting language. 
Also not sure that Ren'Py supports Win 64-bit machines. 

Now I am switching course slightly and would like to write a Python based web 
app on a Windows machine, have it run locally and display the app in the 
browser. The finished product 
would be run on other Windows machines (of varying Windows OS versions) and 
also on Mac machines (of varying Mac OS versions.) The program would present a 
browser based GUI that the 
user would interact with (keying in integer data and clicking buttons) and 
would only have simple computations behind the scenes.

I would like to only do the creation work once and do it on a Windows machine 
(I do not have access to a Mac.) Then be able to run on both other Win machines 
and Mac machines with 
only doing a simple (or not any) installation and without requiring an existing 
Python installation. Also, I do not want the user to need to remain connected 
to the I-net to use the 
app. If they need to connect to the I-net initially to download it that would 
be OK, as long as they could disconnect immediately afterwards and still use 
the app. 

I am sure that I could do something in JavaScript and/or AngularJS, maybe a 
single page app, but I want to do it in Python since that is what I am trying 
to learn. It would be OK if 
it had a small amount of JavaScript, but most of it needs to Python. 

Is this possible? If so, what tools do I use? Can I still use Tkinter for a web 
app? Do I need to do (use) anything to create cross platform executables or 
would running in a 
browser make that step not required?

Sorry for the newbie question, but I am obviously looking for a light switch.
Thanks,Bret

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