09904d7a82992fe2d130bedb2e4a37755fcd6df5
[jamaendo] / jamaui / util.py
1 import os
2 import simplejson
3
4 def string_in_file( filepath, string ):
5     try:
6         f = open( filepath, 'r' )
7         found = f.read().find( string ) != -1
8         f.close()
9     except:
10         found = False
11
12     return found
13
14 def get_platform():
15     if ( os.path.exists('/etc/osso_software_version') or
16          os.path.exists('/proc/component_version') or
17          string_in_file('/etc/issue', 'maemo') ):
18         return 'maemo'
19     else:
20         return 'linux'
21
22 platform = get_platform()
23
24 def jsonprint(x):
25     print simplejson.dumps(x, sort_keys=True, indent=4)