def updateCurrentTag(self, name):
     if self.mshptrail.changeTag(self.currentVersion, name, current_user(),
                              current_time()):
         self.setChanged(True)
         return True
     else:
         return False
Пример #2
0
 def updateCurrentTag(self, name):
     if self.mshptrail.changeTag(self.currentVersion, name, current_user(),
                                 current_time()):
         self.setChanged(True)
         return True
     else:
         return False
Пример #3
0
 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 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
Пример #5
0
 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 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, 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 = self.git_get_latest_version(ref.id)

            # get specific ref.uuid, ref.version combo
            path = self.git_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 = self.git_compute_hash(path, path_type)
            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):
                old_hash = self.git_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')
                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 = self.git_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})
Пример #8
0
    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 = self.git_get_latest_version(ref.id)

            # get specific ref.uuid, ref.version combo
            path = self.git_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 = self.git_compute_hash(path, path_type)
            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):
                old_hash = self.git_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')
                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 = self.git_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
                })