def backup(self, provider): try: os.makedirs(os.path.join(self.dir, provider.id)) except: pass dir = tempfile.mkdtemp() try: for f in provider.list_files(): for x in glob.glob(f): xdir = os.path.join(dir, os.path.split(x)[0][1:]) shell('mkdir -p \'%s\'' % xdir) shell('cp -r \'%s\' \'%s\'' % (x, xdir)) if shell_status('cd %s; tar czf backup.tar.gz *' % dir) != 0: raise Exception() name = 0 try: name = int( os.listdir(self.dir + '/' + provider.id)[0].split('.')[0]) except: pass while os.path.exists('%s/%s/%i.tar.gz' % (self.dir, provider.id, name)): name += 1 shutil.move('%s/backup.tar.gz' % dir, '%s/%s/%s.tar.gz' % (self.dir, provider.id, name)) except: raise finally: shutil.rmtree(dir)
def backup(self, provider): try: os.makedirs(os.path.join(self.dir, provider.id)) except: pass dir = tempfile.mkdtemp() try: for f in provider.list_files(): for x in glob.glob(f): xdir = os.path.join(dir, os.path.split(x)[0][1:]) shell('mkdir -p \'%s\'' % xdir) shell('cp -r \'%s\' \'%s\'' % (x, xdir)) if shell_status('cd %s; tar czf backup.tar.gz *'%dir) != 0: raise Exception() name = 0 try: name = int(os.listdir(self.dir+'/'+provider.id)[0].split('.')[0]) except: pass while os.path.exists('%s/%s/%i.tar.gz'%(self.dir,provider.id,name)): name += 1 shutil.move('%s/backup.tar.gz'%dir, '%s/%s/%s.tar.gz'%(self.dir,provider.id,name)) except: raise finally: shutil.rmtree(dir)
def backup_now(self, provider): try: os.makedirs(os.path.join(self.dir, provider.id)) except: pass dir = tempfile.mkdtemp() try: provider.backup(dir) if shell_status('cd %s; tar -cvpzf backup.tar.gz *' % dir) != 0: raise Exception() name = 0 try: name = int( os.listdir(self.dir + '/' + provider.id)[0].split('.')[0]) except: pass while os.path.exists('%s/%s/%i.tar.gz' % (self.dir, provider.id, name)): name += 1 shutil.move('%s/backup.tar.gz' % dir, '%s/%s/%s.tar.gz' % (self.dir, provider.id, name)) except: raise Exception() finally: shutil.rmtree(dir)
def backup_now(self, provider): try: os.makedirs(os.path.join(self.dir, provider.id)) except: pass dir = tempfile.mkdtemp() try: provider.backup(dir) if shell_status('cd %s; tar -cvpzf backup.tar.gz *'%dir) != 0: raise Exception() name = 0 try: name = int(os.listdir(self.dir+'/'+provider.id)[0].split('.')[0]) except: pass while os.path.exists('%s/%s/%i.tar.gz'%(self.dir,provider.id,name)): name += 1 shutil.move('%s/backup.tar.gz'%dir, '%s/%s/%s.tar.gz'%(self.dir,provider.id,name)) except: raise Exception() finally: shutil.rmtree(dir)
def restore(self, provider, revision): dir = tempfile.mkdtemp() shutil.copy('%s/%s/%s.tar.gz'%(self.dir,provider.id,revision), '%s/backup.tar.gz'%dir) for f in provider.list_files(): for x in glob.glob(f): os.unlink(x) if shell_status('cd %s; tar xf backup.tar.gz -C /'%dir) != 0: raise Exception() os.unlink('%s/backup.tar.gz'%dir) shutil.rmtree(dir)
def restore(self, provider, revision): dir = tempfile.mkdtemp() shutil.copy('%s/%s/%s.tar.gz' % (self.dir, provider.id, revision), '%s/backup.tar.gz' % dir) for f in provider.list_files(): for x in glob.glob(f): os.unlink(x) if shell_status('cd %s; tar xf backup.tar.gz -C /' % dir) != 0: raise Exception() os.unlink('%s/backup.tar.gz' % dir) shutil.rmtree(dir)
def restore_now(self, provider, revision): dir = tempfile.mkdtemp() shutil.copy('%s/%s/%s.tar.gz'%(self.dir,provider.id,revision), '%s/backup.tar.gz'%dir) if shell_status('cd %s; tar -xf backup.tar.gz'%dir) != 0: raise Exception() os.unlink('%s/backup.tar.gz'%dir) try: provider.restore(dir) except: raise finally: shutil.rmtree(dir)
def restore_now(self, provider, revision): dir = tempfile.mkdtemp() shutil.copy('%s/%s/%s.tar.gz' % (self.dir, provider.id, revision), '%s/backup.tar.gz' % dir) if shell_status('cd %s; tar -xf backup.tar.gz' % dir) != 0: raise Exception() os.unlink('%s/backup.tar.gz' % dir) try: provider.restore(dir) except: raise finally: shutil.rmtree(dir)
def verify_dep(dep): """ Verifies that given plugin dependency is satisfied. Returns bool """ if dep[0] == 'app': if shell_status('which '+dep[2]) != 0: raise SoftwareRequirementError(*dep[1:]) if dep[0] == 'plugin': if not dep[1] in PluginLoader.list_plugins() or \ PluginLoader.__plugins[dep[1]].problem: raise PluginRequirementError(*dep[1:]) if dep[0] == 'module': try: exec('import %s'%dep[1]) except: raise ModuleRequirementError(*dep[1:])
def _parse_pm(self, ss): r = {} while len(ss)>0: s = ss[0].split() ss.pop(0) try: if '/' in s[0]: s[0] = s[0].split('/')[1] r[s[0]] = apis.pkgman.Package() r[s[0]].name = s[0] r[s[0]].version = s[1] r[s[0]].description = '' r[s[0]].state = 'installed' if utils.shell_status('pacman -Q '+s[0])==0 else 'removed' while ss[0][0] in ['\t', ' '] and len(ss)>0: r[s[0]].description += ss[0] ss.pop(0) except: pass return r
def _parse_pm(self, ss): r = {} while len(ss) > 0: s = ss[0].split() ss.pop(0) try: if '/' in s[0]: s[0] = s[0].split('/')[1] r[s[0]] = apis.pkgman.Package() r[s[0]].name = s[0] r[s[0]].version = s[1] r[s[0]].description = '' r[s[0]].state = 'installed' if utils.shell_status( 'pacman -Q ' + s[0]) == 0 else 'removed' while ss[0][0] in ['\t', ' '] and len(ss) > 0: r[s[0]].description += ss[0] ss.pop(0) except: pass return r
def test(self): return shell_status("supervisorctl status") == 0
def is_busy(self): if utils.shell_status('ps ax | grep \"/usr/bin/python /usr/bin/yum\" | grep -v \"grep /usr/bin/python /usr/bin/yum\" | awk \'{print $1}\'') != 0: return False return os.path.exists('/tmp/ajenti-yum-output')
def is_busy(self): if utils.shell_status('pgrep zypper') != 0: return False return os.path.exists('/tmp/ajenti-zypper-output')
def is_busy(self): if utils.shell_status('pgrep pacman') != 0: return False return os.path.exists('/tmp/ajenti-pacman-output')
def test(self): return shell_status('supervisorctl status') == 0
def has_param(self, param): return shell_status('grep \'^%s=\' /etc/rc.conf'%param) == 0
def has_param(self, param): return shell_status('grep \'^%s=\' /etc/rc.conf' % param) == 0
def is_busy(self): if utils.shell_status("pgrep apt-get") != 0: return False return os.path.exists("/tmp/ajenti-apt-output")
def has_param(self, param): return shell_status('grep \'%s=\' %s'%(param,self.file)) == 0