def __init__(self, dist=None): if not dist: dist = distro.Distribution().name self.distro = dist if self.is_under_X(): self.name = self.get_wminfo() if self.distro == 'ubuntu' and \ distro.Distribution().version == '11.04' and \ self.name == 'gnome': self.unity_check() self.version = self.get_version() else: self.name = 'console' self.version = None
def create_scriptpkgdesc(dir): dir = os.path.join(dir, distro.Distribution().name+'_def') os.mkdir(dir) for e in ('install','remove'): filepath = os.path.join(dir, '%s.txt' % e) with open(filepath, 'w') as f: f.write("#pkg %s list\n" % e)
def _read(query): dist = distro.Distribution().name if not dist: return [] query = utils.ext_ospath_join(self.path, dist, query) if not os.path.isfile(query): return [] return [ e for e in open(query, 'r').read().split('\n') if not e.startswith('#') and e]
def _ask_user_selectpool(self): conf = env.resource('config') lang = env.get_locale() pools = conf.get_support_pools(distro.Distribution().name, distro.Distribution().version, lang) if not pools: pools = conf.get_support_pools(distro.Distribution().name, distro.Distribution().version, 'en_US') if len(pools) == 1: poolname = pools[0][0] else: poolname = ui.select_defaultpool(pools) self.conf.set_default(pool=poolname) self.conf.save() return poolname
def __init__(self, ui=None): # init runtime_root. env.prepare_runtimeenv() self.ui = ui self.cmd_queue = [] self._scripts = [] self.distro = distro.Distribution() self.pkgmgr = self.distro.pkgmgr
def storageenv(path=None): "Save Bash Shell enviroment variabe." mkexport = lambda val: 'export REAL_%s="%s"' % \ (val.upper(),os.getenv(val.upper())) contents = [ '#!/bin/bash', mkexport('USER'), mkexport('HOME'), mkexport('LANG'), 'export DISTRO_NAME="%s"' % distro.Distribution().name, 'export DISTRO_VERSION="%s"' % distro.Distribution().version, 'export WM_NAME="%s"' % wm.WindowManager().name, ] if wm.WindowManager().version: contents.append('export WM_VERSION="%s"' % wm.WindowManager().version) if distro.Distribution().architecture: contents.append('export DISTRO_ARCHITECTURE="%s"' % distro.Distribution().architecture) if not path: path = DEFAULT_RUNTIME_ROOT_DIR path = os.path.join(path, DEFAULT_STORAGED_ENV_FILE) utils.create_executablefile(path, contents) return path
def gui_run(): from lazyscripts import wm if os.getuid() == 0: print _('console.gui_run.dont_run_as_root') sys.exit() env.register_workspace() env.prepare_runtimeenv() env.storageenv() dist = distro.Distribution().name if not dist: print _('console.gui_run.distro_is_not_supported') sys.exit() message_sudo= _('console.gui_run.gksu_msg') # prefix = 'gksu --message %s' % message_sudo # argument process. parser = optparse.OptionParser() parser.add_option("-a", "--autosync", action="store_true", dest="autosync", default=False, help="sync scripts pool automatically") parser.add_option("-s", "--selection", dest="selection_list") parser.add_option("-r", "--rev", dest="rev") (options, args) = parser.parse_args() if options.autosync: if not options.rev: cmd = "lzs pool sync" else: cmd = "lzs pool sync --rev %s" % options.rev ui.show_progress(cmd, 'Lazyscripts', _('console.gui_run.downloading_scripts'), 80, 400, True, True) if options.selection_list: cmd = "lzs gui run %s" % options.selection_list else: cmd = "lzs gui run" gui_cmd = wm.WindowManager().make_guisudocmd(cmd, message_sudo) os.system(gui_cmd)
def storageenv(path=None): "Save Bash Shell enviroment variabe." mkexport = lambda val: 'export REAL_%s="%s"' % \ (val.upper(),os.getenv(val.upper())) contents = [ '#!/bin/bash', mkexport('USER'), mkexport('HOME'), mkexport('LANG'), 'export DISTRO_ID="%s"' % distro.Distribution().name ] if not path: path = DEFAULT_RUNTIME_ROOT_DIR path = os.path.join(path, 'lzs_storagedenv') utils.create_executablefile(path, contents) return path
def __init__(self, path, recommands_list=None): self.path = path self.recommands_list = recommands_list self.dist = distro.Distribution() self.load()
class __impl: """ Implementation of the singleton interface """ workspace = os.path.join(get_realhome(), '.config', 'lazyscripts') pkgmgr = lzspkgmgr.get_pkgmgr(distro.Distribution().name)
def __init__(self, dist=None): if not dist: dist = distro.Distribution().name self.distro = dist self.name = self.get_wminfo()