Re: Identifying platform in Python code

2007-06-05 Thread Frantisek Dufka
Daniel Stone wrote:
 On Mon, Jun 04, 2007 at 09:49:39PM +0200, ext Frantisek Dufka wrote:
 Jeffrey Barish wrote:
 How do I determine in my code that I am running on the N800?  Neither
 os.name nor sys.platform gets the job done.  The former returns posix,
 the latter linux2, and I get the same strings when I run on Ubuntu.
 Check /etc/osso_software_version file. This is the firmware version. 
 RX-34 on the beginning means N800. Of course this is not very portable 
 and may fail in future but currently it work for both N770 and N800.
 
 If you're going to check the filesystem, hit up /proc/component_version.
 

Right, forgot about that one. /proc/component_version is better for 
knowing specific hardware, osso_software_version is better if you are 
interested in which specific firmware is installed (and in fact for N770 
hacker edition it contains RX-34 by mistake so component_version is 
safer bet).

But the real question is why you want to know it in the first place. 
Maybe there is better way to check some specific feature instead of 
checking hardware version.
___
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers


Re: Identifying platform in Python code

2007-06-05 Thread Jeffrey Barish
Frantisek Dufka wrote:

 But the real question is why you want to know it in the first place.
 Maybe there is better way to check some specific feature instead of
 checking hardware version.

Thanks, all, for the informative answers.  Another good answer came from
Mark Waite, who forgot to copy the mailing list: the Python platform module
provides some useful functions.

I need to know the platform so that I can adjust the GUI.  For example, on
the N800, I probably want to open in fullscreen mode.  It appears that I
will also have to adjust spacing of some GUI elements.  For now, I am using
platform.machine(), although I still wonder why one of os.name or
sys.platform doesn't return maemo.
-- 
Jeffrey Barish

___
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers


Re: Identifying platform in Python code

2007-06-05 Thread Fred Pacquier
Frantisek Dufka a écrit :
 
 Right, forgot about that one. /proc/component_version is better for 
 knowing specific hardware, osso_software_version is better if you are
  interested in which specific firmware is installed (and in fact for
 N770 hacker edition it contains RX-34 by mistake so component_version
 is safer bet).
  But the real question is why you want to know it in the first place.
  Maybe there is better way to check some specific feature instead of
  checking hardware version.

I am not the OP but I also had the same need a while ago and was happy 
to see these answers. I had found the uname hack by myself but maybe 
the file checking is better as it saves importing another module.

My specific problem was determining the screen resolution at the start 
of a pyGame app, to run it fullscreen on the tablet, and windowed on 
other platforms. This does not seem possible from pyGame itself, the 
only workaround I could find was to also import gtk just to use its 
gtk.gdk.screen_width() and gtk.gdk.screen_height() functions once.

As this is a lot of overhead for the tablet, I preferred to detect that 
platform first and set the values manually, and only use gtk detection 
for more powerful platforms. If there's a better way I'd love to know it :-)
___
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers


Re: Identifying platform in Python code

2007-06-05 Thread Fred Pacquier
Marius Gedminas a écrit :

 On Tue, Jun 05, 2007 at 06:42:41PM +0200, Fred Pacquier wrote:
 My specific problem was determining the screen resolution at the start 
 of a pyGame app, to run it fullscreen on the tablet, and windowed on 
 other platforms. This does not seem possible from pyGame itself,
 
 How about taking the largest one from pygame.display.list_modes()?

Thanks Marius for the heads-up : I had toyed with that function while 
exploring the pyGame API, but only on the desktop, and had found it next 
to useless, at least with Windows.

I had not thought of trying it under maemo, where it returns only the 
(800,480) tuple. So it might be a good IT detector with no additional 
import or filesystem access.

 Both approaches will fail when you have a dual-head system -- you'll see
 a large combined display size (e.g. 2308x1024 for a 1024x768+1280x1024
 dual-head mode that crashes pygame when you try to switch to it).  With
 gtk.gdk you can at least find the number of screens and their
 resolutions.


Hmm, I'll admit I hadn't even *thought* of such a possibility :-)
ATM it's not a problem because the app is mostly for my own use, I just 
need a common code base that will adapt to the various platforms and 
screens I use it on - none of which is multi-headed. But I'll keep it in 
mind if/when that happens...

Thanks,
fp
___
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers


Re: Identifying platform in Python code

2007-06-04 Thread Allan Doyle

On Jun 4, 2007, at 12:00, Jeffrey Barish wrote:

 How do I determine in my code that I am running on the N800?  Neither
 os.name nor sys.platform gets the job done.  The former returns  
 posix,
 the latter linux2, and I get the same strings when I run on Ubuntu.

You can parse it out of something like

import commands
id = commands.getoutput(uname -a)

if id has Linux Nokia-N800 in it, it's an N800
if id has Linux Nokia770 in it, it's a 770

This may change over time with newer versions of the OS but it works  
for now.


-- 
Allan Doyle
http://museum.mit.edu/mwow
+1.781.433.2695




___
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers


Re: Identifying platform in Python code

2007-06-04 Thread Frantisek Dufka
Jeffrey Barish wrote:
 How do I determine in my code that I am running on the N800?  Neither
 os.name nor sys.platform gets the job done.  The former returns posix,
 the latter linux2, and I get the same strings when I run on Ubuntu.

Check /etc/osso_software_version file. This is the firmware version. 
RX-34 on the beginning means N800. Of course this is not very portable 
and may fail in future but currently it work for both N770 and N800.

Frantisek

___
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers


Re: Identifying platform in Python code

2007-06-04 Thread Daniel Stone
On Mon, Jun 04, 2007 at 09:49:39PM +0200, ext Frantisek Dufka wrote:
 Jeffrey Barish wrote:
  How do I determine in my code that I am running on the N800?  Neither
  os.name nor sys.platform gets the job done.  The former returns posix,
  the latter linux2, and I get the same strings when I run on Ubuntu.
 
 Check /etc/osso_software_version file. This is the firmware version. 
 RX-34 on the beginning means N800. Of course this is not very portable 
 and may fail in future but currently it work for both N770 and N800.

If you're going to check the filesystem, hit up /proc/component_version.

Cheers,
Daniel


signature.asc
Description: Digital signature
___
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers