Re: Very stupid question.

2006-03-31 Thread Juha-Matti Tapio
Peter Hansen <[EMAIL PROTECTED]> wrote:
>  >>> from path import path
>  >>> path('foobar').getsize()
> 12345L
> (But note that it's just a nice wrapper around the scattered builtin 
> ways of doing the same thing, in this case the os.stat().st_size 
> approach mentioned above.  That's not a bad thing, though, IMHO.)

Also if the file in question is already open, it can be done like this:

os.fstat(fileobject.fileno()).st_size

This form avoids some race condition scenarious with the file being changed 
between stat and open.

I think file sizes should be used carefully and only for visual reasons. 
For code logic it is almost always better to go the "it's easier to ask 
forgiveness than ask permission" -route. Therefore looking up the file size 
is done only rarely and it is not worthy to be a file-object method.

-- 
Juha-Matti Tapio - fil.yo. - +358-50-5419230
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Coin-operated kiosk written in python -- need some help...

2005-08-20 Thread Juha-Matti Tapio
Jon Monteleone <[EMAIL PROTECTED]> wrote:
> The OS I am using is linux distro fedora core 4 (RH, version 10 I think).  
> The first
> question I have is exactly as you mention in 1.  I need to have the gui 
> running from
> machine bootup to shutdown.  I wrote a bash daemon init script to turn my 
> program into a
> daemon, but it doesnt seem to work.  I used the standard bash daemon init 
> script that
> exists in /usr/local/docs as a template.  The script doesnt work correctly, 
> so that is my
> first problem.  But, assuming I get the script spawning my program as a 
> daemon, the
> question becomes...will my Tkinter gui show up on the gnome presession screen 
> (login
> screen) or do I need to add special code in .xinitrc or some other file to 
> make it
> display?
> So, currently my specific questions are:
> 1) How do I make my gui display at the login screen (we can assume I get the 
> program
> spawning as a daemon)

Assuming Gnome and GDM as a display manager, you can access the login
display by setting the environment variable
XAUTHORITY=/var/lib/gdm/:0.Xauth before starting your Tkinter-script.

That environment variable specifies the file where the MIT
authorization cookie for the X11-session is stored. If Gdm is not
used, the file is going to be somewhere else.

> 2) How do I get a push of the start button on my gui to login the user to the 
> Internet
> account

I think there is some kind of support in Gdm to support auto-login, but
personally I would suggest not using Gdm at all. You could start X11
separately from your script, then open your Gui on the display, and
start gnome-session (with a proper userid) on the same display after the 
user has paid. (Though you need to be careful with security so that the 
user can't bypass your system.)

You would propably get better advice from some Linux or Gnome -specific
forums. From a Python viewpoint you basically just need to know that
the python-process running your Gui can access the X authority file 
specified in the above mentioned environment variable.

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