Here are the examples of the python api platform.release taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
36 Examples
5
Example 1
Project: nightmare Source File: linux.py
def setupPtraceOptions(self, tid):
"""
Called by doAttachThread to setup ptrace related options.
"""
opts = PT_O_TRACESYSGOOD
print "platform.release()", platform.release()
if platform.release().startswith("2.6") or platform.release().startswith("3"):
opts |= PT_O_TRACECLONE
x = v_posix.ptrace(PT_SETOPTIONS, tid, 0, opts)
if x != 0:
libc.perror('ptrace PT_SETOPTION failed for thread %d' % tid)
3
Example 2
Project: scapy Source File: __init__.py
def get_windows_if_list():
if platform.release()=="post2008Server" or platform.release()=="8":
# This works only starting from Windows 8/2012 and up. For older Windows another solution is needed
query = exec_query(['Get-NetAdapter'],
['Name', 'InterfaceIndex', 'InterfaceDescription',
'InterfaceGuid', 'MacAddress'])
else:
query = exec_query(['Get-WmiObject', 'Win32_NetworkAdapter'],
['Name', 'InterfaceIndex', 'InterfaceDescription',
'GUID', 'MacAddress'])
return [
iface for iface in
(dict(zip(['name', 'win_index', 'description', 'guid', 'mac'], line))
for line in query)
if is_interface_valid(iface)
]
3
Example 3
def read_routes():
routes = []
release = platform.release()
try:
if release in ["post2008Server", "8"]:
routes = read_routes_post2008()
elif release == "XP":
routes = read_routes_xp()
else:
routes = read_routes_7()
except Exception as e:
log_loading.warning("Error building scapy routing table : %s"%str(e))
else:
if not routes:
log_loading.warning("No default IPv4 routes found. Your Windows release may no be supported and you have to enter your routes manually")
return routes
3
Example 4
def check_windows_wallet_migration():
if platform.release() != "XP":
if os.path.exists(os.path.join(os.environ["LOCALAPPDATA"], "Electrum")):
if os.path.exists(os.path.join(os.environ["APPDATA"], "Electrum")):
print_msg("Two Electrum folders have been found, the default Electrum location for Windows has changed from %s to %s since Electrum 1.7, please check your wallets and fix the problem manually." % (os.environ["LOCALAPPDATA"], os.environ["APPDATA"]))
sys.exit()
try:
shutil.move(os.path.join(os.environ["LOCALAPPDATA"], "Electrum"), os.path.join(os.environ["APPDATA"]))
print_msg("Your wallet has been moved from %s to %s."% (os.environ["LOCALAPPDATA"], os.environ["APPDATA"]))
except:
print_msg("Failed to move your wallet.")
3
Example 5
Project: MurDocK Source File: dockSERVER.py
def sysCheck():
sysInfo = []
sysInfo.append("OS : " + OS)
sysInfo.append("FAMILY : " + os.name)
sysInfo.append("RELEASE : " + platform.release())
sysInfo.append("PLAT : " + platform.platform())
sysInfo.append("ARCH : " + platform.machine())
sysInfo.append("HOST : " + platform.node())
sysInfo.append("UNAME : " + getuser())
if OS == "Windows" :
sysInfo.append("UID : NULL")
elif OS == "Linux" :
sysInfo.append("UID : " + str(os.geteuid()))
sysInfo.append("PID : " + str(os.getpid()))
return str(sysInfo)
3
Example 6
Project: vivisect Source File: linux.py
@v_base.threadwrap
def setupPtraceOptions(self, tid):
"""
Called per pid/tid to setup proper options
for ptrace.
"""
opts = PT_O_TRACESYSGOOD
if platform.release()[:3] in ('2.6','3.0','3.1','3.2'):
opts |= PT_O_TRACECLONE | PT_O_TRACEEXIT
x = v_posix.ptrace(PT_SETOPTIONS, tid, 0, opts)
if x != 0:
libc.perror('ptrace PT_SETOPTION failed for thread %d' % tid)
3
Example 7
def check_windows_wallet_migration():
if platform.release() != "XP":
path = os.path.join(os.environ["LOCALAPPDATA"], "Electrum")
if os.path.exists(path):
if os.path.exists(os.path.join(os.environ["APPDATA"], "Electrum")):
print_msg("Two Electrum folders have been found, the " +
"default Electrum location for Windows has " +
"changed from %s to %s since Electrum 1.7, " +
"please check your wallets and fix the problem " +
"manually." %
(os.environ["LOCALAPPDATA"], os.environ["APPDATA"]))
sys.exit()
try:
shutil.move(path, os.path.join(os.environ["APPDATA"]))
print_msg("Your wallet has been moved from %s to %s." %
(os.environ["LOCALAPPDATA"], os.environ["APPDATA"]))
except:
print_msg("Failed to move your wallet.")
3
Example 8
Project: two1-python Source File: doctor.py
def check_general_operating_system_release(self):
""" Checks if the OS version is supported
Returns:
Check.Result, str, str: Result of the check
Human readable message describing the check
Operating system version,
e.g. "4.4.14-11.x86_64"
"""
check_str = "OS Kernel Version"
actual_os_version = platform.release()
# Always return success, but display actual OS version to
# help with debugging
return Check.Result.PASS, check_str, actual_os_version
3
Example 9
Project: deluge Source File: common.py
def vista_check():
"""
Checks if the current platform is Windows Vista
:returns: True or False
:rtype: bool
"""
return platform.release() == 'Vista'
3
Example 10
Project: mcedit Source File: mcplatform.py
def Lion():
try:
import distutils.version
import platform
lionver = distutils.version.StrictVersion('10.7')
curver = distutils.version.StrictVersion(platform.release())
return curver >= lionver
except Exception, e:
print "Error getting system version: ", repr(e)
return False
3
Example 11
def _expand(self, path):
log.debug("Expanding: {}".format(path))
if self.os == "linux" or self.os == "darwin":
return os.path.expanduser(path)
elif self.os == "windows" and platform.release() != "XP":
return os.path.expandvars(path)
else:
log.error("Unsupported OS: {} - expanding failed.".format(self.os))
return None
0
Example 12
Project: raspmedia Source File: ImageTransferNotebook.py
def UdpListenerStopped(self):
global playerCount
Publisher.unsubscribe(self.HostFound, 'host_found')
if self.hostSearch:
self.hostSearch = False
print "%d player found" % playerCount
if playerCount == 0:
self.prgDialog.Update(100)
if HOST_SYS == HOST_WIN:
self.prgDialog.Destroy()
if platform.release() == "XP":
dlgWin = wx.MessageDialog(self,wordwrap(tr("no_players_found"), 300, wx.ClientDC(self)), tr("no_player"), style=wx.OK)
result = dlgWin.ShowModal()
self.parent.Close()
dlg = wx.SingleChoiceDialog(self,wordwrap(tr("no_players_found"), 300, wx.ClientDC(self)), tr("no_player"), ["Enter IP Address", tr("rescan"), tr("exit")])
result = dlg.ShowModal()
selection = dlg.GetSelection()
if result == wx.ID_OK:
if selection == 0: # ENTER IP
ipDlg = wx.TextEntryDialog(self, "Enter the IP of your RaspMedia Player or Exit application with cancel.", "Enter IP Address");
if ipDlg.ShowModal() == wx.ID_OK:
ipAddress = ipDlg.GetValue()
self.HostFound([ipAddress, "RaspMedia"], "RaspMedia")
self.LoadControlWindowForCurrentHostList()
else:
self.parent.Close()
elif selection == 1: # RESCAN
self.SearchHosts()
elif selection == 2: # EXIT
self.parent.Close()
elif result == wx.ID_CANCEL:
self.parent.Close()
else:
self.LoadControlWindowForCurrentHostList()
0
Example 13
Project: raspmedia Source File: RemoteNotebook.py
def UdpListenerStopped(self):
global playerCount
Publisher.unsubscribe(self.UdpListenerStopped, 'listener_stop')
Publisher.unsubscribe(self.HostFound, 'host_found')
if self.hostSearch:
self.hostSearch = False
if playerCount == 0:
self.prgDialog.Update(100)
if HOST_SYS == HOST_WIN:
self.prgDialog.Destroy()
if platform.release() == "XP":
dlgWin = wx.MessageDialog(self,wordwrap(tr("no_players_found"), 300, wx.ClientDC(self)), tr("no_player"), style=wx.OK)
result = dlgWin.ShowModal()
self.parent.Close()
dlg = wx.SingleChoiceDialog(self,wordwrap(tr("no_players_found"), 300, wx.ClientDC(self)), tr("no_player"), ["Enter IP Address", tr("rescan"), tr("exit")])
result = dlg.ShowModal()
selection = dlg.GetSelection()
if result == wx.ID_OK:
if selection == 0: # ENTER IP
ipDlg = wx.TextEntryDialog(self, "Enter the IP of your RaspMedia Player or Exit application with cancel.", "Enter IP Address");
if ipDlg.ShowModal() == wx.ID_OK:
ipAddress = ipDlg.GetValue()
self.HostFound([ipAddress, "RaspMedia"], "RaspMedia")
self.LoadControlWindowForCurrentHostList()
else:
self.parent.Close()
elif selection == 1: # RESCAN
self.SearchHosts()
elif selection == 2: # EXIT
self.parent.Close()
elif result == wx.ID_CANCEL:
self.parent.Close()
else:
self.LoadControlWindowForCurrentHostList()
0
Example 14
def test_release(self):
res = platform.release()
0
Example 15
def main():
release = platform.release()
bootfile, procfile = '/boot/config-%s' % release, '/proc/config.gz'
if len(sys.argv) > 1 and os.path.isfile(sys.argv[1]):
print('Config found at supplied file')
openf, filename = open, sys.argv[1]
elif os.path.isfile(bootfile):
print('Config found at %s' % bootfile)
openf, filename = open, bootfile
elif os.path.isfile(procfile):
import gzip
print('Config found at %s' % procfile)
openf, filename = gzip.open, procfile
else:
print('Config not found!')
return
with openf(filename) as config:
# assuming config file was not edited manually, as kernel config
# helpers write "# CONFIG_OVERLAY_FS is not set" when disabled
haystack = config.read()
if isinstance(haystack, bytes):
haystack = haystack.decode()
if 'CONFIG_OVERLAY_FS=' in haystack:
print('overlayfs is available :)')
else:
print('overlayfs is not available :(')
0
Example 16
Project: scalarizr Source File: lvm2.py
@staticmethod
def usable():
if Lvm2._usable is None:
Lvm2._usable = False
try:
coreutils.modprobe('dm_snapshot')
coreutils.modprobe('dm_mod')
Lvm2._usable = True
except:
try:
import platform
release = platform.release()
kernel_config_path = "/boot/config-" + release
if os.path.isfile(kernel_config_path):
with open(kernel_config_path) as f:
kernel_config = f.readlines()
drivers_compiled = dict(CONFIG_BLK_DEV_DM=False,
CONFIG_DM_SNAPSHOT=False)
for line in kernel_config:
for driver_name in drivers_compiled.keys():
if line.startswith(driver_name):
drivers_compiled[driver_name] = line.strip().split('=')[1] == 'y'
if all(drivers_compiled.values()):
Lvm2._usable = True
except:
pass
return Lvm2._usable
0
Example 17
def get_os_release():
"""Get the leading numeric component of the OS release."""
return re.match('[\d.]+', platform.release()).group(0)
0
Example 18
Project: ZenPacks.zenoss.Microsoft.Windows Source File: __init__.py
def install(self, app):
super(ZenPack, self).install(app)
self.register_devtype(app.zport.dmd)
log.info(SEGFAULT_INFO)
try:
exchange_version = self.dmd.ZenPackManager.packs._getOb(
'ZenPacks.zenoss.Microsoft.Exchange').version
if IMPACT_INSTALLED and \
exchange_version in ('1.0.0', '1.0.1', '1.0.2'):
log.warn(EXCH_WARN)
except AttributeError:
pass
# copy kerberos.so file to python path
osrelease = platform.release()
kerbsrc = os.path.join(os.path.dirname(__file__), 'lib', getOSKerberos(osrelease), 'kerberos.so')
kerbdst = zenPath('lib', 'python')
shutil.copy(kerbsrc, kerbdst)
# Set KRB5_CONFIG environment variable
userenvironconfig = '{0}/.bashrc'.format(os.environ['HOME'])
if 'KRB5_CONFIG' not in open(userenvironconfig).read():
environmentfile = open(userenvironconfig, "a")
environmentfile.write('# Following value required for Windows ZenPack\n')
environmentfile.write('export KRB5_CONFIG="{0}/var/krb5/krb5.conf"\n'.format(
os.environ['ZENHOME']))
environmentfile.close()
# add symlinks for command line utilities
for utilname in self.binUtilities:
self.installBinFile(utilname)
self.cleanup_zProps(app.zport.dmd)
0
Example 19
def get_kernel():
return platform.release()
0
Example 20
Project: coinbox-core Source File: environ.py
@classmethod
def is_windows_vista(cls):
"""Returns True on Windows Vista"""
return platform.release() == "Vista"
0
Example 21
Project: LaZagne Source File: network.py
def run(self, software_name = None):
os_plateform = platform.release()
a = self.get_creds()
pwd = ''
pwdFound = []
if a:
for i in a:
values = {}
if i['Type'] == win32cred.CRED_TYPE_GENERIC:
cipher_text = i['CredentialBlob']
if os_plateform == 'XP':
pwd = self.Win32CryptUnprotectData(cipher_text, self.get_entropy())
else:
pwd = cipher_text
if pwd != 'failed':
targetName = i['TargetName'].replace('Microsoft_WinInet_', '')
values['URL'] = targetName
if os_plateform == 'XP':
t = targetName.split('/')
targetName = t[0]
if i['UserName'] is not None:
values['Login'] = i['UserName']
try:
values['Password'] = pwd.decode('utf16')
except Exception,e:
print_debug('DEBUG', '{0}'.format(e))
values['INFO'] = 'Error decoding the password'
pwdFound.append(values)
return pwdFound
else:
print_debug('INFO', 'No credentials listed with the enum cred function')
0
Example 22
Project: indicator-sysmonitor Source File: sensors.py
def _fetch_mem(self):
"""It gets the total memory info and return the used in percent."""
def grep(pattern, word_list):
expr = re.compile(pattern)
arr = [elem for elem in word_list if expr.match(elem)]
return arr[0]
with open('/proc/meminfo') as meminfofile:
meminfo = meminfofile.readlines()
total = SensorManager.digit_regex.findall(grep("MemTotal", meminfo))[0]
release = re.split('\.', platform.release())
major_version = int(release[0])
minor_version = int(re.search(r'\d+', release[1]).group())
if (minor_version >= 16 and major_version == 3) or (major_version > 3):
available = SensorManager.digit_regex.findall(
grep("MemAvailable", meminfo))[0]
return 100 - 100 * int(available) / float(total)
else:
free = SensorManager.digit_regex.findall(
grep("MemFree", meminfo))[0]
cached = SensorManager.digit_regex.findall(
grep("Cached", meminfo))[0]
free = int(free) + int(cached)
return 100 - 100 * free / float(total)
0
Example 23
def get_platform_name(withversion=False):
"""Try and determine platform name
e.g., x86_64-unknown-linux, x86_64-apple-darwin
"""
os_type = get_os_type()
release = platform.release()
machine = platform.machine()
if os_type == LINUX:
vendor = 'unknown'
release = '-gnu'
elif os_type == DARWIN:
vendor = 'apple'
else:
raise SystemToolsException("Failed to determine platform name, unknown system name: %s" % os_type)
platform_name = '%s-%s-%s' % (machine, vendor, os_type.lower())
if withversion:
platform_name += release
return platform_name
0
Example 24
Project: chopper Source File: exp_executor.py
def run_and_get_df(self, treatment, savedf=False):
"""
This function will run the experiment for this treatment,
and append the resulting dataframe to the result file
"""
# put treatment info to a dataframe which will be written to result file
df = pyWorkload.pat_data_struct.treatment_to_df_morefactors(treatment)
# put response to df
ret = self.get_response(treatment)
# calculate the ideal distance_sum
ideal_sum = MWpyFS.Monitor.\
extent_distant_sum({'off':None,
'len':treatment['unique.bytes']})
df.addColumn(key = 'dspan', value=ret['d_span'])
assert ret['distance_sum'] >= ideal_sum, \
"{} {} {}".format(ret['distance_sum'], ideal_sum, treatment['unique.bytes'])
df.addColumn(key = 'layout_index',
value = ret['distance_sum']/float(ideal_sum))
df.addColumn(key = 'treatment_id',
value = datetime.datetime.now().strftime("%m-%d-%H-%M-%S.%f"))
df.addColumn(key = 'node_id',
value = '.'.join(socket.gethostname().split('.')[0:2]))
df.addColumn(key = 'kernel.release',
value = platform.release())
df.addColumn(key = 'datafiles',
value = ret['datafiles'])
df.addColumn(key = 'datafiles_dspan',
value = ret['datafiles_dspan'])
df.addColumn(key = 'num_extents',
value = ret['num_extents'])
##############################3
# do some clean up
# writer_cpu_map fullness
# open_bitmap close_bitmap
# nchunks writer_pid
# n_virtual_cores write_order
# filesize sync_bitmap
# parent_dirid chunks
# fileid fsync_bitmap
# filechunk_order disksize
# dir_depth filesystem
# disk_used dspan
# treatment_id node_id
tokeep = [
'write_order', 'filesize',
'sync_bitmap', 'fsync_bitmap',
'nchunks',
'n_virtual_cores',
'disksize', 'disk_used',
'dspan', 'fullness',
'jobid', 'filesystem',
'dir.span', 'num.files',
'layout_index',
'layoutnumber',
'kernel.release',
'datafiles',
'datafiles_dspan',
'num_extents'
]
headers = copy.deepcopy(df.header)
for colname in headers:
if not colname in tokeep:
df.delColumn(colname)
# keep only one row
del df.table[1:]
translate_dic = {
'write_order':'chunk.order',
'filesize':'file.size',
'sync_bitmap':'sync',
'fsync_bitmap':'fsync',
'nchunks':'num.chunks',
'n_virtual_cores':'num.cores',
'parent_dirid':'dir.id',
'disksize':'disk.size',
'disk_used':'disk.used',
'filesystem':'file.system'
}
for i,k in enumerate(df.header):
if translate_dic.has_key(k):
df.header[i] = translate_dic[k]
if savedf:
if self.fileout == None:
self.fileout = open(
chpConfig.parser.get('system', 'resulttablepath'), 'w')
self.fileout.write(df.toStr(header=True, table=True))
else:
self.fileout.write(df.toStr(header=False, table=True))
return df
0
Example 25
@pyqtSlot(result = str)
def release(self):
return platform.release()
0
Example 26
Project: ansible-modules-extras Source File: openbsd_pkg.py
def parse_package_name(name, pkg_spec, module):
module.debug("parse_package_name(): parsing name: %s" % name)
# Do some initial matches so we can base the more advanced regex on that.
version_match = re.search("-[0-9]", name)
versionless_match = re.search("--", name)
# Stop if someone is giving us a name that both has a version and is
# version-less at the same time.
if version_match and versionless_match:
module.fail_json(msg="package name both has a version and is version-less: " + name)
# If name includes a version.
if version_match:
match = re.search("^(?P<stem>.*)-(?P<version>[0-9][^-]*)(?P<flavor_separator>-)?(?P<flavor>[a-z].*)?$", name)
if match:
pkg_spec['stem'] = match.group('stem')
pkg_spec['version_separator'] = '-'
pkg_spec['version'] = match.group('version')
pkg_spec['flavor_separator'] = match.group('flavor_separator')
pkg_spec['flavor'] = match.group('flavor')
pkg_spec['style'] = 'version'
else:
module.fail_json(msg="unable to parse package name at version_match: " + name)
# If name includes no version but is version-less ("--").
elif versionless_match:
match = re.search("^(?P<stem>.*)--(?P<flavor>[a-z].*)?$", name)
if match:
pkg_spec['stem'] = match.group('stem')
pkg_spec['version_separator'] = '-'
pkg_spec['version'] = None
pkg_spec['flavor_separator'] = '-'
pkg_spec['flavor'] = match.group('flavor')
pkg_spec['style'] = 'versionless'
else:
module.fail_json(msg="unable to parse package name at versionless_match: " + name)
# If name includes no version, and is not version-less, it is all a stem.
else:
match = re.search("^(?P<stem>.*)$", name)
if match:
pkg_spec['stem'] = match.group('stem')
pkg_spec['version_separator'] = None
pkg_spec['version'] = None
pkg_spec['flavor_separator'] = None
pkg_spec['flavor'] = None
pkg_spec['style'] = 'stem'
else:
module.fail_json(msg="unable to parse package name at else: " + name)
# If the stem contains an "%" then it needs special treatment.
branch_match = re.search("%", pkg_spec['stem'])
if branch_match:
branch_release = "6.0"
if version_match or versionless_match:
module.fail_json(msg="package name using 'branch' syntax also has a version or is version-less: " + name)
if StrictVersion(platform.release()) < StrictVersion(branch_release):
module.fail_json(msg="package name using 'branch' syntax requires at least OpenBSD %s: %s" % (branch_release, name))
pkg_spec['style'] = 'branch'
# Key names from description in pkg_add(1).
pkg_spec['pkgname'] = pkg_spec['stem'].split('%')[0]
pkg_spec['branch'] = pkg_spec['stem'].split('%')[1]
# Sanity check that there are no trailing dashes in flavor.
# Try to stop strange stuff early so we can be strict later.
if pkg_spec['flavor']:
match = re.search("-$", pkg_spec['flavor'])
if match:
module.fail_json(msg="trailing dash in flavor: " + pkg_spec['flavor'])
0
Example 27
Project: Radium-Keylogger Source File: network.py
def run(self):
os_plateform = platform.release()
a = self.get_creds()
pwd = ''
pwdFound = []
if a:
for i in a:
values = {}
if i['Type'] == win32cred.CRED_TYPE_GENERIC:
cipher_text = i['CredentialBlob']
if os_plateform == 'XP':
pwd = self.Win32CryptUnprotectData(cipher_text, self.get_entropy())
else:
pwd = cipher_text
if pwd != 'failed':
targetName = i['TargetName'].replace('Microsoft_WinInet_', '')
values['TargetName'] = targetName
if os_plateform == 'XP':
t = targetName.split('/')
targetName = t[0]
if i['UserName'] is not None:
values['Username'] = i['UserName']
try:
values['Password'] = pwd.decode('utf16')
except Exception, e:
#print e
values['INFO'] = 'Error decoding the password'
pwdFound.append(values)
# print the results
return pwdFound
else:
print 'No credentials listed with the enum cred function'
0
Example 28
def _get_profiles(self):
if self.os == 'windows':
if platform.release() == "XP":
log.error("Unsupported OS (Windows XP). Returning None")
return None
# todo: Check if it's possible for folder to be in %APPDATA%
# instead
profiles_folder = self._expand("%LOCALAPPDATA%\\Google\\Chrome Canary\\User Data\\")
elif self.os == "darwin":
profiles_folder = self._expand("~/Library/Application Support/Google/Chrome Canary/")
else:
log.error("Unsupported OS. Returning None")
return None
available_profiles = {}
# Check if default directory exists
default_profile = os.path.join(profiles_folder, "Default")
if os.path.exists(default_profile):
available_profiles['Default'] = default_profile
log.debug("Default profile exists")
for other_profile in glob(profiles_folder+os.sep+"Profile *"):
try:
profile_name = other_profile.split(os.sep)[-1:][0]
except Exception as e:
log.exception(e)
log.debug("Additional profile {} at {} exists".format(profile_name,
other_profile))
available_profiles[profile_name] = other_profile
return available_profiles
0
Example 29
def _get_res(self, profile_name):
log.debug("searching for RES")
res_file = "chrome-extension_kbmfpngjjgdllneeigpgjifpgocmfgmb_0.localstorage"
if self.os == 'windows':
if platform.release() == "XP":
log.error("Unsupported OS (Windows XP). Returning None")
return None
# todo: Check if it's possible for folder to be in %APPDATA% instead
res_folder = self._expand("%LOCALAPPDATA%\\Google\\Chrome Canary\\User Data\\{}\\Local Storage\\".format(profile_name))
elif self.os == "darwin":
res_folder = self._expand("~/Library/Application Support/Google/Chrome Canary/{}/Local Storage/".format(profile_name))
else:
log.error("Unsupported OS. Returning None")
return None
log.debug("res_folder set to : {}".format(res_folder))
if not os.path.exists(res_folder):
log.error("Selected folder does not exist")
return None
try:
full_path = os.path.join(res_folder, res_file)
log.debug("Full path set to {}".format(full_path))
if os.path.exists(full_path):
log.debug("Full path exists")
return full_path
else:
log.warn("Full path does not exist. RES Not installed?")
return None
except AttributeError:
log.error("Joining failed for {} and {}".format(res_folder, res_file))
return None
except Exception as e:
log.exception(e)
0
Example 30
def _get_profiles(self):
if self.os == 'linux':
profiles_folder = self._expand("~/.config/google-chrome")
elif self.os == 'windows':
if platform.release() == "XP":
log.error("Unsupported OS (Windows XP). Returning None")
return None
# todo: Check if it's possible for folder to be in %APPDATA%
# instead
profiles_folder = self._expand("%LOCALAPPDATA%\\Google\\Chrome\\User Data\\")
elif self.os == "darwin":
profiles_folder = self._expand("~/Library/Application Support/Google/Chrome/")
else:
log.error("Unsupported OS. Returning None")
return None
available_profiles = {}
# Check if default directory exists
default_profile = os.path.join(profiles_folder, "Default")
if os.path.exists(default_profile):
available_profiles['Default'] = default_profile
log.debug("Default profile exists")
for other_profile in glob(profiles_folder+os.sep+"Profile *"):
try:
profile_name = other_profile.split(os.sep)[-1:][0]
except Exception as e:
log.exception(e)
log.debug("Additional profile {} at {} exists".format(profile_name,
other_profile))
available_profiles[profile_name] = other_profile
return available_profiles
0
Example 31
def _get_res(self, profile_name):
log.debug("searching for RES")
res_file = "chrome-extension_kbmfpngjjgdllneeigpgjifpgocmfgmb_0.localstorage"
if self.os == 'linux':
res_folder = self._expand("~/.config/google-chrome/{}/Local Storage/".format(profile_name))
elif self.os == 'windows':
if platform.release() == "XP":
log.error("Unsupported OS (Windows XP). Returning None")
return None
# todo: Check if it's possible for folder to be in %APPDATA% instead
res_folder = self._expand("%LOCALAPPDATA%\\Google\\Chrome\\User Data\\{}\\Local Storage\\".format(profile_name))
elif self.os == "darwin":
res_folder = self._expand("~/Library/Application Support/Google/Chrome/{}/Local Storage/".format(profile_name))
else:
log.error("Unsupported OS. Returning None")
return None
log.debug("res_folder set to : {}".format(res_folder))
if not os.path.exists(res_folder):
log.error("Selected folder does not exist")
return None
try:
full_path = os.path.join(res_folder, res_file)
log.debug("Full path set to {}".format(full_path))
if os.path.exists(full_path):
log.debug("Full path exists")
return full_path
else:
log.warn("Full path does not exist. RES Not installed?")
return None
except AttributeError:
log.error("Joining failed for {} and {}".format(res_folder, res_file))
return None
except Exception as e:
log.exception(e)
0
Example 32
def _get_profiles(self):
if self.os == 'linux':
profiles_folder = self._expand("~/.config/chromium")
elif self.os == 'windows':
if platform.release() == "XP":
log.error("Unsupported OS (Windows XP). Returning None")
return None
# todo: Check if it's possible for folder to be in %APPDATA%
# instead
profiles_folder = self._expand("%LOCALAPPDATA%\\Chromium\\User Data\\")
elif self.os == "darwin":
profiles_folder = self._expand("~/Library/Application Support/Chromium/")
else:
log.error("Unsupported OS. Returning None")
return None
available_profiles = {}
# Check if default directory exists
default_profile = os.path.join(profiles_folder, "Default")
if os.path.exists(default_profile):
available_profiles['Default'] = default_profile
log.debug("Default profile exists")
for other_profile in glob(profiles_folder+os.sep+"Profile *"):
try:
profile_name = other_profile.split(os.sep)[-1:][0]
except Exception as e:
log.exception(e)
log.debug("Additional profile {} at {} exists".format(profile_name,
other_profile))
available_profiles[profile_name] = other_profile
return available_profiles
0
Example 33
def _get_res(self, profile_name):
log.debug("searching for RES")
res_file = "chrome-extension_kbmfpngjjgdllneeigpgjifpgocmfgmb_0.localstorage"
if self.os == 'linux':
res_folder = self._expand("~/.config/chromium/{}/Local Storage/".format(profile_name))
elif self.os == 'windows':
if platform.release() == "XP":
log.error("Unsupported OS (Windows XP). Returning None")
return None
# todo: Check if it's possible for folder to be in %APPDATA% instead
res_folder = self._expand("%LOCALAPPDATA%\\Chromium\\User Data\\{}\\Local Storage\\".format(profile_name))
elif self.os == "darwin":
res_folder = self._expand("~/Library/Application Support/Chromium/{}/".format(profile_name))
else:
log.error("Unsupported OS. Returning None")
return None
log.debug("res_folder set to : {}".format(res_folder))
if not os.path.exists(res_folder):
log.error("Selected folder does not exist")
return None
try:
full_path = os.path.join(res_folder, res_file)
log.debug("Full path set to {}".format(full_path))
if os.path.exists(full_path):
log.debug("Full path exists")
return full_path
else:
log.warn("Full path does not exist. RES Not installed?")
return None
except AttributeError:
log.error("Joining failed for {} and {}".format(res_folder, res_file))
return None
except Exception as e:
log.exception(e)
0
Example 34
def _get_profiles(self):
log.info("Getting firefox profiles")
if self.os == 'linux':
profiles_folder = self._expand("~/.mozilla/firefox/")
elif self.os == 'windows':
if platform.release() == "XP":
log.error("Unsupported OS (Windows XP). Returning None")
return None
profiles_folder = self._expand("%APPDATA%\\Mozilla\\Firefox\\")
elif self.os == "darwin":
profiles_folder = self._expand("~/Library/Mozilla/Firefox/")
if not os.path.exists(profiles_folder):
profiles_folder = self._expand("~/Library/Application Support/Firefox/")
else:
log.error("Unsupported OS. Returning None")
return None
log.debug("Firefox profiles root folder set to {}".format(profiles_folder))
if not os.path.exists(profiles_folder):
log.error("profiles_folder does not exists, returning {}")
return {}
try:
profiles_path = os.path.join(profiles_folder, "profiles.ini")
log.debug("profiles.ini path: {}".format(profiles_path))
except AttributeError:
log.error("Joining folder and profiles.ini failed. Returning None")
return {}
except Exception as e:
log.exception(e)
return {}
if not os.path.exists(profiles_path):
# If profiles.ini does not exist no profile folder exists either
# or does it...
log.error("Profiles path not found. New FF installation?. Returning None")
return {}
profiles = ConfigParser.RawConfigParser()
profiles.read(profiles_path)
profiles.remove_section('General')
available_profiles = {}
for index, profile in enumerate(profiles.sections()):
name = profiles.get(profiles.sections()[index], 'Name')
path = profiles.get(profiles.sections()[index], 'Path')
available_profiles[name] = path
log.debug("Profiles:{}".format(available_profiles))
return available_profiles
0
Example 35
def _get_res(self, profile_name):
log.debug("Getting firefox path for profile name: {}".format(profile_name))
ff_profile = self.available_profiles.get(profile_name)
res_file = "jetpack/jid1-xUfzOsOFlzSOXg@jetpack/simple-storage/store.json"
if not ff_profile:
log.error("Could not get selected profile path for {}".format(profile_name))
return None
if self.os == 'linux':
res_folder = self._expand("~/.mozilla/firefox/")
elif self.os == 'windows':
if platform.release() == "XP":
log.error("Unsupported OS (Windows XP). Returning None")
return None
res_folder = self._expand("%APPDATA%\\Mozilla\\Firefox\\")
elif self.os == "darwin":
res_folder = self._expand("~/Library/Mozilla/Firefox/")
if not os.path.exists(res_folder):
res_folder = self._expand("~/Library/Application Support/Firefox/")
else:
log.error("Unsupported OS: {} Returning None".format(self.os))
return None
log.debug("Firefox res_folder set to: {}".format(res_folder))
try:
full_path = os.path.join(res_folder, ff_profile, res_file)
log.debug("Full firefox path set to {}".format(full_path))
if os.path.exists(full_path):
log.debug("Full firefox path exists")
return full_path
else:
log.error("Full firefox path does not exist. RES Not installed?")
return None
except AttributeError:
log.error("Firefox joining failed for {}, {} and {}".format(res_folder, ff_profile, res_file))
return None
except Exception as e:
log.exception(e)
0
Example 36
Project: cyg-apt Source File: setup.py
def _cygwinVersion(self):
return float(platform.release()[:3]);