Download .jpg from web

2005-01-06 Thread GMane Python
Hello All.
  Using a network camera with built-in webserver, I'd like to have a python
program download .jpg files on a local lan.  the location is
http:///jpg/image.jpg.

  Currently, I'm importing urllib and using urlopen to the address, then
read()-ing it, saving it to a binary file.  All that is working great, but
maybe a bit slowly.  I'm getting ~2.3 frames per second, and would like
between 5-10 frames per second.

  Am I approaching this incorrectly?  I have to do a urlopen, then .read()
for each image.  Is there any way to 'persist' the urlopen so I just have to
keep read()-ing or maybe is there a type of streaming read?  I have many
cameras, so there are many threads simultaneously reading and dropping them
in a central Queue for saving later.

  I appreciate it!
-Dave

 WebImage = urllib.urlopen("http:///jpg/image.jpg").read()
 QueuePacket = []
 QueuePacket.append(WebImage)




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


Automatic Windows printer creation?

2005-01-19 Thread GMane Python
Anyone know if there's a module which will allow me to 'create' windows
printer definitions?  Not from a Windows domain network, but just to add a
printer that sends to a jet-direct-attached printer.

Thanks!
Dave



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


Re: Python choice of database

2005-06-21 Thread GMane Python
For my database, I have a table of user information with a unique
identifier, and then I save to the filesystem my bitmap files, placing the
unique identifier, date and time information into the filename.  Why stick a
photo into a database?

For instance:

User Table:
uniqueID: 0001
lNane: Rose
fName: Dave

Then save the bitmap with filename:
0001_13:00:00_06-21-2005.bmp

To make things faster, I also have a table of filenames saved, so I can know
exactly which files I want to read in.

-Dave



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


Invoke ffmpeg from MySQL

2005-07-05 Thread GMane Python
Hello All.
  First, I'd like to thank you all for the tremendous help I've received in
the past while posting here.  I'd like to ask another question.

  I'd like to use Python to invoke ffmpeg to encode some still-frames into
an animation.  I'd like to use MySQL to store the frames as a BLOB object.
I'd like to know if anyone can help me with the invocation syntax.  If I
had, say, 10,000 frames stored in the database, how would I be able to send
to ffmpeg without needing to write them to the hard-drive first, for
encoding.  Ultimately, I'd like a 2-pass, but would settle for 1-pass
right-away.

Thank you!
Dave Rose



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


Save Binary data.

2005-08-19 Thread GMane Python
Hello All.
  I have a program that downloads 'gigabytes' of Axis NetCam photos per day.
Right now, I set up the process to put the images into a queue, and every 30
or so seconds, 'pop' them from the queue and save them to disc.   I save
them as individual files.

  I think that I'd like to modify it to save into one file 100-200 images,
so that I don't have directories with 50,000-90,000 frames before handing
that off to a DivX Encoder.

  I don't know if I need to use something like cPickle, or maybe just save
them as a binary data file (which would be a temp file until later in the
day when I open it to begin the encoding process.)

Can someone please help me with some direction?


Thank you!
Dave



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


Netware Python?

2005-08-19 Thread GMane Python
Hello all.  Looking, I have not found a version of Python which runs on
Netware by Novell.  I wonder, since Java there is a Java for Netware, is
this where Jython would come in as useful, to be able to use a Python script
where Java is installed?

I'm interested in the threaded heartbeat program in the cookbook for my
Netware environment, to be connected to a nice graphical front end on my
Win32 station, to know when servers are up or down (well, since Netware is
hardly ever down, when the WAN links are up or down)

-dave



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


Time Difference

2004-12-17 Thread GMane Python
Hello
  I was wondering if there is an existing function that would let me
determine the difference in time.  To explain:

Upon starting a program:

startup = time.time()

After some very long processing:
now = time.time()

print, now - startup

So, to print in a formatted way (D-H-M-S) the difference in time of startup
and now.

Thanks!
Dave



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


PyHeartBeat Client in PERL?

2004-12-27 Thread GMane Python
  Hello Everyone.

Whil e reading the Python Cookbook as a means of learning Python, I
came across the script by Nicola Larosa.  Not knowing anything about PERL, I
was wondering if there were a translation in PERL so I could have my Netware
servers send heartbeats to the heartbeat server?  Thanks!

  Dave



  Title: PyHeartbeat - detecting inactive computers
  Submitter: Nicola Larosa





  # Filename: HeartbeatClient.py

  """Heartbeat client, sends out an UDP packet periodically"""

  import socket, time

  SERVER_IP = '127.0.0.1'; SERVER_PORT = 43278; BEAT_PERIOD = 5

  print ('Sending heartbeat to IP %s , port %d\n'
  'press Ctrl-C to stop\n') % (SERVER_IP, SERVER_PORT)
  while True:
  hbSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  hbSocket.sendto('PyHB', (SERVER_IP, SERVER_PORT))
  if __debug__: print 'Time: %s' % time.ctime()
  time.sleep(BEAT_PERIOD)




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


python sane imaging

2004-12-28 Thread GMane Python
Anyone know where the python sane imaging module is?  Searching google, I
can't find it to download.  I have a win32 & linux system --  hope to find
it for both OSes.

Dave



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


Scanner Access in Python

2005-04-13 Thread GMane Python
Hello All!
  I was hoping for a bit of advise.  I wanted to know if anyone has any
experience with scanning.  I'm mostly using Windows.  I tried quickly the
pyTwain, but haven't gotten too far with that.  I'm not sure if scanner
access is built-in to other packages, such as maybe PIL or any others?  I
have a Canoscan Lide-50 & Lide 30.

 Thanks!

Dave



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


Pickle an image?

2005-04-25 Thread GMane Python
Hey all.
  I have a ( list | tuple | dictionary ) with several graphics in it.
Trying to cPickle it to a file, I get errors.  For instance,
UnpickleableError: Cannon pickle  objects.

  Anyone know of a way to get around this?  I'd like to pickle a list or
dictionary of about 5 .JPG images.

Thanks!
Dave



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


Re: OOP

2005-04-29 Thread GMane Python
As with most things, you have to understand 'why' you want to do something
before you can really understand how it applies.

Ok.  Go to amazon.  They've setup a 'shopping cart'.  That cart is made of
variables, name, cred.card num, items, quantity of items, ship-to address,
state, shipping cost, shipping type, tax (if applicable), etc.  Ok.  If you
have a program and want this info, ok, you could set up variables for all of
them.

What if you now have 2 shopping carts?  How do you double the variables?
What if you now have 1000 shopping carts?  How do you scale your programming
so what works for 1 works for 1000?

OOP allows you to create a 'structure' of the variables, and when someone
enters their name in a field and hits, 'add to cart' , abstractly, you'll
have a structure in your program like:

User = ShoppingCartClass()

Now, you defined User to be an object of ShoppingCartClass.

Now, methods are pre-defined actions.  You might have:
.Checkout()
.DeleteItem()
.AddItem()

and of course inside the parenthesis, you'd have relevent info. for the
routine.

So maybe you'd do:
User = ShoppingCartClass()
User.AddItem(sku=5)
User.DeleteItem(sku=22)
User.CheckOut(State='CT', CredCard='Visa', CredNum='1234-5678-8765-4321')

So, there's the why. This just barely scratches the surface. hope I didn't
confuse you.

-Dave
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hey yall,
> I'm new to Python and I love it. Now I can get most of the topics
> covered with the Python tutorials I've read but the one thats just
> stumping me is Object Orientation. I can't get the grasp of it. Does
> anyone know of a good resource that could possibly put things in focus
> for me? Thanks.
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>



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


Re: Forgot my wrapup of example! Sorry!

2005-05-02 Thread GMane Python
So, I forgot the last part of my example that might gel in your mind why
Objects are useful in certain situations.  Ok so you maybe followed my
example of the shopping cart.  Let's just forget for a moment the use for
shopping carts is for  websites.  Let's just say you were going to write the
lines directly into Python, like maybe at the IDLE interpreter.  Like maybe
you're testing the functionality of the routine for correctness, not actual
implementation.



You have a ShoppingCartClass(), and three users-> Dave, Tommy, Bryan.

ShoppngCartClass() has 3 methods:

.AddItem()

.RemoveItem()

.CheckOut()



These are really just def routintes you write in the class to do some action
or calculation.  Here, we want to either add an item to 'the cart', remove
one, or finalize the order.



In the interpreter,  you could do this. Define 3 users of the
ShoppingCartClass.



Dave = ShoppingCartClass()

Tommy = ShoppingCartClass()

Bryan = ShoppingCartClass()





Ok.  Now you could do different things to each:



Dave.AddItem(sku=5)

Tommy.AddItem(sku=77)

Tommy.AddItem(sku=12)

Tommy.RemoveItem(sku=12)

Dave.CheckOut(state=CT, ccard='visa', ccardnum='1234-5678-8765-431')

Tommy.CheckOut(stsate=RI, ccard='mastercard', ccardnum='431-123-4321-1234')

Bryan.CancelOrder()



so, if you were then to take account of what you had, you'd know:

Dave has item SKU=5

Tommy has item SKU=77

Bryan has his order cancelled.



This is still very hard-coded.  You could abstract, or maybe variablize,
things more. Let's try:



You can mix classes with say dictionaries, to make their use in routines
more beneficial.



So, you could have:



user = "Dave"

ShoppingCart={}

ShoppingCart[user] = ShoppingCartClass()

user = "Tommy"

ShoppingCart[user] = ShoppingCartClass()

user = "Dave"

ShoppingCart[user].AddItem(sku=55)

user = "Tommy"

ShoppingCart[user].CheckOut( ... )

ShoppingCart["Dave"].CheckOut( ... )



Putting the classes in the dictionary allow you to use names from things
like fields, config files, text files, TextControls in my favorite program
wxPython, etc.



In a class, you can have a variable 'total' and you can have a variable
'self.total'.  The first is just accessible from within the structure of the
class.  The latter is accessible from outside the class.  So, using a class
with the variable self.total, you can from outside the class say:



print ShoppingCart["Dave"].total



to get the value of the variable self.total.  (That had me buggered for a
while . )



If you can wrap your mind around this, you're well on your way to using OOP
I believe.  If not, , don't give up. I'm just a python/programming newbie
and maybe missed the boat completely with my posting.



Another quite important part I didn't even mention was sub-classing.  That's
taking a class, and 'inheriting' it's code to your class as a base, then you
can re-write or adddifferent methods.  But, first I think it's important to
understand how to have several instances of a single class running in
memory, each with different values for the defined variables.  I'll let
someone else talk about that.



-Dave



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


Re: Byte-operations.

2005-05-19 Thread GMane Python
For anyone who cares out there, I tried a slice with hex values:

IDLE 1.0.3
>>> a
=['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17
','18','19','20']
>>> print a[3:4]
['4']
>>> print a[0xa:0xc]
['11', '12']
>>> print a[0xa:0xa+5]
['11', '12', '13', '14', '15']

-Dave

"Jeff Epler" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]

>In Python, "chr" gives a 1-byte string from a small integer, "ord" does
>the reverse.  Strings are concatenated with "+" and substrings are taken
>with the slice operator, s[pos1:pos2].

>I'm not a visual basic expert, but it looks like these are the
>operations the code below performs.

>Jeff

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



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


py2exe for WMI

2005-05-24 Thread GMane Python
Hello All.
  I'm trying to 'compile-to-EXE' a python program which uses Win32 & WMI to
pull system info. from the PC such as serial number, CPU speed, etc.  I'm
having problems with py2exe -- with regard to Win2000 & WinXP platforms.  It
seems that the program only works if I have one typelib for WinXP and a
slightly different one for Win2000.  Here is my relevent section from the
py2exe setup.py:
setup(
options = {"py2exe": {"typelibs":
##  # typelib for WMI - WinXP
##  [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0,
1, 2)],

  # typelib for WMI - Win2000
  [('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1,
1)],

  # create a compressed zip archive
  "compressed": 1,
  "optimize": 2,
  "packages": ["encodings"],
  "excludes": excludes}},
# The lib directory contains everything except the executables and the
python dll.
# Can include a subdirectory name.
zipfile = "lib/shared.zip",

Can anyone tell me how I might make one unified py2exe setup.py that'll
'compile' for both Win2000 & WinXP?

If not, can someone give me a hint as to how I can have a python 'launcher'
which can determine the difference between Win2000 & WinXP?  Using the
sys.platform, they both show as Win32.

Thanks!
Dave



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


Re: "...Learning with Python" ...a property that addition andmultiplication have...

2005-05-26 Thread GMane Python
The inablility to work with negative values.

Addition can do the following:
5 + (-4)  read as 5 plus the value negative four.

Multiplication can do the following:
5 * (-1) read as 5 times the value negative one.

String concatination can not subtract the sub-string 'lo' from 'hello'.
'hello' - 'lo' is invalid.

string repetition can not repeat a value negative times:
'hello' * -3 is invalid.
'hello' * 2.75 is also invalid, in that you can not repeat a fractional
amount.

-Dave
(Python Newbie)
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Greetings.
>
> I'm reading "How to think like a computer scientist: Learning with
> Python" and there's a question regarding string operations. The
> question is, "Can you think of a property that addition and
> multiplication have that string concatenation and repetition do not?"
>
> I thought it was the commutative property but ""*3 is
> equivalent to 3*"". Any ideas?
>
> Thanks,
>
> Jeff
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>



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


Seti-like program

2005-05-31 Thread GMane Python
Hello

I'd like to consider making a program which is 'seti-like' where I could run
a command-line Python script to just 'do something', and then be able to
launch a viewer program (maybe linux x11 or Windows, possibly over a network
socket) using wxPython to be able to inter-act with it. (Start jobs, view
queue of jobs, modify jobs, etc, or even just watch the work process).

I was wondering if anyone out there had any experience with this, maybe had
an example to share.

I consider [EMAIL PROTECTED] a good example, also maybe Arcserve backup program 
with
manager.

-Dave



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


Re: Seti-like program

2005-05-31 Thread GMane Python
I want to have a program download pictures from a netCam (Axis 2100).  So, I
want to start & stop, and also see progress (how many photos, are there
errors, did I begin encoding to DivX, etc) for multiple cameras.

-Dave
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Other examples- PCAnyWhere, a Trojan Horse .. :)
>
> Anyway, this is quite simple.
> All you realy need is a server with a GUI that listens all the time for
> incoming connections,
> and a client that will connect to the server and work in the
> background.
>
> Here are some thoughts...
>
> - Figure out what action you want the client to do. Make sure you
> have a working script that does that already, that could later be
> connected to the actual client.
> - How much control do you need over the client? do you want to just
> send commands and see the result? or do you want to recieve
> screenshots, or even "live" view of the client?
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>



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


Re: Reading a CSV file into a list of dictionaries

2005-06-07 Thread GMane Python
Sounds like you want to use the ConfigObject module.

http://www.voidspace.org.uk/python/modules.shtml#configobj

-dave

"RFQ" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi, I'm struggling here to do the following with any success:
>
> I have a comma delimited file where each line in the file is something
> like:
>
> PNumber,3056,Contractor,XYZ Contracting,Architect,ABC Architects,...
>
> So each line is intended to be: key1,value1,key2,value2,key3,value3...
> and each line is to be variable in length (although it will have to be
> an even number of records so that each key has a value).
>
> I want to read in this csv file and parse it into a list of
> dictionaries. So each record in the list is a dictionary:
>
> {"PNumber":"3056","Contractor":"XYZ Contracting", ... }
>
> I have no problem reading in the CSV file to a list and splitting each
> line in the file into its comma separated values. But I can't figure
> out how to parse each resulting list into a dictionary.
>
> Any help on this?
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>



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