1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# Copyright (C) 2010 Sebastian Dziallas
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
import os
import logging
import re
import subprocess
from gettext import gettext as _
import errno
import linecache
from jarabe import config
_not_available = _('Not available')
def submit_profile():
subprocess.call(['smoltSendProfile', '-a'])
def delete_profile():
subprocess.call(['smoltDeleteProfile'])
os.remove(os.getenv("HOME") + '/.smolt/uuiddb.cfg')
def get_profile_url():
uuiddb = os.getenv("HOME") + '/.smolt/uuiddb.cfg'
if os.path.exists(uuiddb):
database = linecache.getline(uuiddb, 2)
profile = database[55:]
profile_url = 'http://www.smolts.org/client/show/' + profile
else:
profile_url = _not_available
return profile_url
def print_profile_url():
profile_url = get_profile_url()
if profile_url is None:
profile_url = _not_available
print profile_url
def _read_file(path):
if os.access(path, os.R_OK) == 0:
return None
fd = open(path, 'r')
value = fd.read()
fd.close()
if value:
value = value.strip('\n')
return value
else:
_logger.debug('No information in file or directory: %s', path)
return None
def get_policy():
policy_file = os.path.join('/usr/share/smolt/doc/', 'PrivacyPolicy')
try:
fd = open(policy_file)
# remove 0x0c page breaks which can't be rendered in text views
policy_text = fd.read().replace('\x0c', '')
fd.close()
except IOError:
policy_text = _not_available
return policy_text
|