Fix a bug in the Maemo code
[panucci.git] / src / panucci / platform.py
blob7415359b9d68920017e5874172f153a7fdb38a68
1 # -*- coding: utf-8 -*-
3 # This file is part of Panucci.
4 # Copyright (c) 2008-2010 The Panucci Audiobook and Podcast Player Project
6 # Panucci is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # Panucci is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Panucci. If not, see <http://www.gnu.org/licenses/>.
20 from __future__ import absolute_import
22 import os.path
24 # Variables that can be used to query platform status
25 MAEMO = False
26 FREMANTLE = False
27 DESKTOP = True
30 def file_contains(filename, content):
31 try:
32 for line in open(filename):
33 if content in line:
34 return True
35 except:
36 return False
39 def detect():
40 """Detect current environment
42 This should be called once from the launcher.
43 """
44 global MAEMO
45 global FREMANTLE
46 global DESKTOP
48 if os.path.exists('/etc/osso_software_version') or \
49 os.path.exists('/proc/component_version') or \
50 file_contains('/etc/issue/', 'maemo'):
51 MAEMO = True
52 DESKTOP = False
54 # Check for Maemo 5 (fremantle)
55 if file_contains('/etc/issue', 'Maemo 5'):
56 MAEMO = True
57 FREMANTLE = True
58 DESKTOP = False