def create (self) : assert not sos.path.exists (self.db_uri), self.db_uri.name assert not sos.path.exists (self.x_uri), self.x_uri.name x_uri = self.x_uri with TFL.lock_file (x_uri) : sos.mkdir (x_uri) sos.system ("chmod go= %s" % x_uri.name) self._create_info ()
def create (self) : assert not sos.path.exists (self.db_uri.name), self.db_uri.name assert not sos.path.exists (self.x_uri.name), self.x_uri.name x_name = self.x_uri.name with TFL.lock_file (x_name) : sos.mkdir (x_name) sos.system ("chmod go= %s" % x_name) self._create_info ()
def load_info (self) : assert sos.path.exists (self.db_uri), self.db_uri.name x_uri = self.x_uri with TFL.lock_file (x_uri) : if not sos.path.exists (x_uri) : sos.mkdir (x_uri) sos.system ("chmod go= %s" % x_uri.name) with contextlib.closing \ (self.ZF.ZipFile (self.db_uri, "r")) as zf : zf.extractall (x_uri) self.info = self._load_info ()
def load_info (self) : assert sos.path.exists (self.db_uri.name), self.db_uri.name x_name = self.x_uri.name with TFL.lock_file (x_name) : if not sos.path.exists (x_name) : sos.mkdir (x_name) sos.system ("chmod go= %s" % x_name) with contextlib.closing \ (self.ZF.ZipFile (self.db_uri.name, "r")) as zf : zf.extractall (x_name) self.info = self._load_info ()
def system (self, key = "view", filename = "/dev/null", plist = []) : cmd = self.command (key, filename, plist) if self.needsterminal : cmd = "xterm -e %s" % cmd return sos.system (cmd)
def applicable (self, filename = "/dev/null", plist = []) : if self.test : test_cmd = self.command ("test", filename, plist) return sos.system (test_cmd) == 0 return True