Coverage for lutris.util.system : 39%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Execute a system command and result its results """ stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
""" Return the md5 hash of filename. """ md5 = hashlib.md5() try: with open(filename, 'rb') as f: for chunk in iter(lambda: f.read(8192), b''): md5.update(chunk) except IOError: print "Error reading %s" % filename return False return md5.hexdigest()
return execute(['pgrep', program])
assert str(int(pid)) == str(pid) execute(['kill', '-9', pid])
cwd_file = '/proc/%d/cwd' % int(pid) if not os.path.exists(cwd_file): return False return os.readlink(cwd_file)
cmdline_path = '/proc/%d/cmdline' % int(pid) if not os.path.exists(cmdline_path): return False return open(cmdline_path, 'r').read().replace('\x00', ' ').strip()
logger.error("python_identifier requires a string, got %s", string) return
return files[fileid]
logger.debug("Merging %s into %s", source, destination) for (dirpath, dirnames, filenames) in os.walk(source): source_relpath = dirpath[len(source) + 1:] dst_abspath = os.path.join(destination, source_relpath) for dirname in dirnames: new_dir = os.path.join(dst_abspath, dirname) logger.debug("creating dir: %s" % new_dir) try: os.mkdir(new_dir) except OSError: pass for filename in filenames: logger.debug("Copying %s" % filename) if not os.path.exists(dst_abspath): os.makedirs(dst_abspath) shutil.copy(os.path.join(dirpath, filename), os.path.join(dst_abspath, filename))
""" Given a folder path, tells if it safe to remove it """ if not path: return False if not os.path.exists(path): return False if path in excludes: return False
parts = path.strip('/').split('/') if parts[0] in ('usr', 'var', 'lib', 'etc', 'boot', 'sbin', 'bin'): # Path is part of the system folders return False
if parts[0] == 'home' and len(parts) == 2: # Path is a home folder return False
return True |