def updateCurrentTag(self, name): if self.mshptrail.changeTag(self.currentVersion, name, current_user(), current_time()): self.setChanged(True) return True else: return False
def moveTag(self, from_version, to_version, name): tag = self.mshptrail.getTagForActionId(from_version) if tag: self.mshptrail.removeTagByActionId(from_version) self.mshptrail.addTag(to_version, tag, user=current_user(), date=current_time())
def compute(self): server = self.get_input('server') \ if self.has_input('server') else 'localhost' port = self.get_input('port') \ if self.has_input('port') else 22 username = self.get_input('username') \ if self.has_input('username') else current_user() password = self.get_input('password') \ if self.has_input('password') else '' self.machine = Machine.create_machine(server, username, password, port) self.set_output("value", self.machine)
def compute(self): server = self.getInputFromPort('server') \ if self.hasInputFromPort('server') else 'localhost' port = self.getInputFromPort('port') \ if self.hasInputFromPort('port') else 22 username = self.getInputFromPort('username') \ if self.hasInputFromPort('username') else current_user() password = self.getInputFromPort('password') \ if self.hasInputFromPort('password') else '' self.machine = BQMachine(server, username, password, port) # force creation of server-side help files select_machine(self.machine) end_machine() self.setResult("value", self)
def setup_git(self): config_stack = self.repo.get_config_stack() try: config_stack.get(('user', ), 'name') config_stack.get(('user', ), 'email') except KeyError: from vistrails.core.system import current_user from dulwich.config import ConfigFile user = current_user() repo_conf = self.repo.get_config() repo_conf.set(('user', ), 'name', user) repo_conf.set(('user', ), 'email', '%s@localhost' % user) repo_conf.write_to_path()
def setup_git(self): config_stack = self.repo.get_config_stack() try: config_stack.get(('user',), 'name') config_stack.get(('user',), 'email') except KeyError: from vistrails.core.system import current_user from dulwich.config import ConfigFile user = current_user() repo_conf = self.repo.get_config() repo_conf.set(('user',), 'name', user) repo_conf.set(('user',), 'email', '%s@localhost' % user) repo_conf.write_to_path()
def createMashupVersion(self, alias_list, quiet=False): id = self.id_scope.getNewId('mashup') mashup = Mashup(id=id, name="mashup%s"%id, vtid=self.currentMashup.vtid, version=self.currentMashup.version, alias_list=alias_list) currVersion = self.mshptrail.addVersion(parent_id=self.currentVersion, mashup=mashup, user=current_user(), date=current_time()) self.mshptrail.currentVersion = currVersion self.currentMashup = mashup #print "created new mashup ", currVersion self.setCurrentVersion(currVersion, quiet) self.setChanged(True) return currVersion
def createMashupVersion(self, alias_list, quiet=False): id = self.id_scope.getNewId('mashup') mashup = Mashup(id=id, name="mashup%s" % id, vtid=self.currentMashup.vtid, version=self.currentMashup.version, alias_list=alias_list) currVersion = self.mshptrail.addVersion(parent_id=self.currentVersion, mashup=mashup, user=current_user(), date=current_time()) self.mshptrail.currentVersion = currVersion self.currentMashup = mashup #print "created new mashup ", currVersion self.setCurrentVersion(currVersion, quiet) self.setChanged(True) return currVersion
def get_default_machine(self): """ Reads the default machine from the package configuration """ server = username = port = password = '' if configuration.check('server'): server = configuration.server if not server: return None if configuration.check('username'): username = configuration.username if not username: username = current_user() if configuration.check('port') is not None: port = configuration.port if configuration.check('password'): password = configuration.password self.annotate({'RemoteQ-server':server, 'RemoteQ-username':username, 'RemoteQ-port':port}) return server, port, username, password
def get_default_machine(self): """ Reads the default machine from the package configuration """ server = username = port = password = '' if configuration.check('server'): server = configuration.server if not server: return None if configuration.check('username'): username = configuration.username if not username: username = current_user() if configuration.check('port') is not None: port = configuration.port if configuration.check('password'): password = configuration.password self.annotate({ 'RemoteQ-server': server, 'RemoteQ-username': username, 'RemoteQ-port': port }) return server, port, username, password
def compute(self, is_input=None, path_type=None): global db_access if not self.hasInputFromPort('value') and \ not self.hasInputFromPort('ref'): raise ModuleError(self, "Need to specify path or reference") if self.persistent_path is not None: debug_print('using persistent path') ref = self.persistent_ref path = self.persistent_path elif self.hasInputFromPort('ref'): ref = self.getInputFromPort('ref') if ref.id is None: ref.id = str(uuid.uuid1()) else: # create a new reference ref = PersistentRef() ref.id = str(uuid.uuid1()) if self.hasInputFromPort('localPath'): ref.local_path = self.getInputFromPort('localPath').name if self.hasInputFromPort('readLocal'): ref.local_read = self.getInputFromPort('readLocal') if self.hasInputFromPort('writeLocal'): ref.local_writeback = self.getInputFromPort('writeLocal') if is_input is None: is_input = False if not self.hasInputFromPort('value'): is_input = True else: if ref.local_path and ref.local_read: debug_print('found local path with local read') is_input = True # FIXME: check if the signature is the signature of # the value if so we know that it's an input... # if just reference, pull path from repository (get latest # version unless specified as specific version) if self.persistent_path is None and not self.hasInputFromPort('value') \ and is_input and not (ref.local_path and ref.local_read): _, suffix = os.path.splitext(ref.name) if not db_access.ref_exists(ref.id, ref.version): raise ModuleError(self, "Persistent entity '%s' does not " "exist in the local repository." % ref.id) if ref.version is None: ref.version = repo.get_current_repo().get_latest_version(ref.id) # get specific ref.uuid, ref.version combo path = repo.get_current_repo().get_path(ref.id, ref.version, out_suffix=suffix) elif self.persistent_path is None: # copy path to persistent directory with uuid as name if is_input and ref.local_path and ref.local_read: debug_print('using local_path') path = ref.local_path else: path = self.getInputFromPort('value').name # this is a static method so we need to add module ourselves try: new_hash = repo.get_current_repo().compute_hash(path) except ModuleError, e: e.module = self raise e rep_path = os.path.join(local_db, ref.id) do_update = True if os.path.exists(rep_path): if os.path.isdir(rep_path): actual_type = 'tree' elif os.path.isfile(rep_path): actual_type = 'blob' else: raise ModuleError(self, "Path is something not a file or " "a directory") if path_type is None: path_type = actual_type else: if path_type != actual_type: def show_type(t): if t == 'tree': return "directory" elif t == 'blob': return "file" else: return '"%s"' % t raise ModuleError(self, "Path is not a %s but a %s" % ( show_type(path_type), show_type(actual_type))) old_hash = repo.get_current_repo().get_hash(ref.id, path_type=path_type) debug_print('old_hash:', old_hash) debug_print('new_hash:', new_hash) if old_hash == new_hash: do_update = False if do_update: debug_print('doing update') if path_type == 'tree': if (not os.path.exists(path) or not os.listdir(path)): raise ModuleError(self, "This directory is empty") self.copypath(path, os.path.join(local_db, ref.id)) # commit (and add to) repository # get commit id as version id # persist object-hash, commit-version to repository version = repo.get_current_repo().add_commit(ref.id) ref.version = version # write object-hash, commit-version to provenance if is_input: signature = new_hash else: signature = self.signature db_access.write_database({'id': ref.id, 'name': ref.name, 'tags': ref.tags, 'user': current_user(), 'date_created': current_time(), 'date_modified': current_time(), 'content_hash': new_hash, 'version': version, 'signature': signature, 'type': path_type})
def compute(self, is_input=None, path_type=None): global db_access if not self.has_input('value') and \ not self.has_input('ref'): raise ModuleError(self, "Need to specify path or reference") if self.persistent_path is not None: debug_print('using persistent path') ref = self.persistent_ref path = self.persistent_path elif self.has_input('ref'): ref = self.get_input('ref') if ref.id is None: ref.id = str(uuid.uuid1()) else: # create a new reference ref = PersistentRef() ref.id = str(uuid.uuid1()) if self.has_input('localPath'): ref.local_path = self.get_input('localPath').name if self.has_input('readLocal'): ref.local_read = self.get_input('readLocal') if self.has_input('writeLocal'): ref.local_writeback = self.get_input('writeLocal') if is_input is None: is_input = False if not self.has_input('value'): is_input = True else: if ref.local_path and ref.local_read: debug_print('found local path with local read') is_input = True # FIXME: check if the signature is the signature of # the value if so we know that it's an input... # if just reference, pull path from repository (get latest # version unless specified as specific version) if self.persistent_path is None and not self.has_input('value') \ and is_input and not (ref.local_path and ref.local_read): _, suffix = os.path.splitext(ref.name) if not db_access.ref_exists(ref.id, ref.version): raise ModuleError( self, "Persistent entity '%s' does not " "exist in the local repository." % ref.id) if ref.version is None: ref.version = repo.get_current_repo().get_latest_version( ref.id) # get specific ref.uuid, ref.version combo path = repo.get_current_repo().get_path(ref.id, ref.version, out_suffix=suffix) elif self.persistent_path is None: # copy path to persistent directory with uuid as name if is_input and ref.local_path and ref.local_read: debug_print('using local_path') path = ref.local_path else: path = self.get_input('value').name # this is a static method so we need to add module ourselves try: new_hash = repo.get_current_repo().compute_hash(path) except ModuleError, e: e.module = self raise e rep_path = os.path.join(local_db, ref.id) do_update = True if os.path.exists(rep_path): if os.path.isdir(rep_path): actual_type = 'tree' elif os.path.isfile(rep_path): actual_type = 'blob' else: raise ModuleError( self, "Path is something not a file or " "a directory") if path_type is None: path_type = actual_type else: if path_type != actual_type: def show_type(t): if t == 'tree': return "directory" elif t == 'blob': return "file" else: return '"%s"' % t raise ModuleError( self, "Path is not a %s but a %s" % (show_type(path_type), show_type(actual_type))) old_hash = repo.get_current_repo().get_hash( ref.id, path_type=path_type) debug_print('old_hash:', old_hash) debug_print('new_hash:', new_hash) if old_hash == new_hash: do_update = False if do_update: debug_print('doing update') if path_type == 'tree': if (not os.path.exists(path) or not os.listdir(path)): raise ModuleError(self, "This directory is empty") self.copypath(path, os.path.join(local_db, ref.id)) # commit (and add to) repository # get commit id as version id # persist object-hash, commit-version to repository version = repo.get_current_repo().add_commit(ref.id) ref.version = version # write object-hash, commit-version to provenance if is_input: signature = new_hash else: signature = self.signature db_access.write_database({ 'id': ref.id, 'name': ref.name, 'tags': ref.tags, 'user': current_user(), 'date_created': current_time(), 'date_modified': current_time(), 'content_hash': new_hash, 'version': version, 'signature': signature, 'type': path_type })