Esempio n. 1
0
def setPartition(mdplug, state):
    """Make all sets of the given data message plug use a partition or not
    :param state: if True, a partition will be used, if False, it will be disabled
    :note: this method makes sure that all sets are hooked up to the partition
    :raise ValueError: If we did not have a single set to which to add to the partition
    :raise AttributeError: If the dataID has never had sets
    :return: if state is True, the name of the possibly created (or existing) partition"""
    sets = setsByPlug(mdplug)
    pt = partition(mdplug)

    if state:
        if pt is None:
            if not sets:
                raise ValueError("Cannot create partition as plug %s did not have any connected sets" % mdplug)
            # END check sets exist
            # create partition
            pt = createNode("storagePartition", "partition", forceNewLeaf=True)

            tattr = api.MFnTypedAttribute()
            attr = tattr.create(StorageBase.kPartitionIdAttr, "pid", api.MFnData.kString)
            pt.addAttribute(attr)
        # END create partition

        # make sure all sets are members of our partition
        pt.addSets(sets)
        return pt
    else:
        if pt:
            # delete partition
            # have to clear partition as, for some reason, or own node will be killed as well !
            pt.clear()
            delete(pt)
Esempio n. 2
0
	def setPartition( self, dataID, state ):
		"""Make all sets in dataID use a partition or not
		
		:param dataID: id identifying the storage plug
		:param state: if True, a partition will be used, if False, it will be disabled
		:note: this method makes sure that all sets are hooked up to the partition
		:raise ValueError: If we did not have a single set to which to add to the partition
		:raise AttributeError: If the dataID has never had sets
		:return: if state is True, the name of the possibly created ( or existing ) partition"""
		sets = self.setsByID( dataID )
		partition = self.partition( dataID )

		if state:
			if partition is None:
				if not sets:
					raise ValueError("Cannot create partition as data %r did not have any connected sets" % dataID)
				# END check sets exist
				# create partition
				partition = createNode( "storagePartition", "partition", forceNewLeaf=True )

				tattr = api.MFnTypedAttribute( )
				attr = tattr.create( self._partitionIdAttr, "pid", api.MFnData.kString )
				partition.addAttribute( attr )
			# END create partition

			# make sure all sets are members of our partition
			partition.addSets( sets )
			return partition
		else:
			if partition:
				# delete partition
				# have to clear partition as, for some reason, or own node will be killed as well !
				partition.clear()
				delete( partition )
Esempio n. 3
0
def shedule_delete():
    if flask.session.get("user_id") not in bot.admins:
        return "Login please", 200

    event_id = flask.request.form["id"]

    base.delete(bot, event_id)
    return flask.redirect("/shedule")
Esempio n. 4
0
def shedule_edit():
    if flask.session.get("user_id") not in bot.admins:
        return "Login please", 200

    event_id = flask.request.form["id"]
    print(flask.request.form)
    event_date, event_time = flask.request.form["date"].split()
    title = flask.request.form["title"]

    base.delete(bot, event_id)
    base.add(bot, event_id, title, event_date, event_time)
    return flask.redirect("/shedule")
Esempio n. 5
0
def deleteObjectSet(mdplug, setIndex):
    """Delete the object set at the given message data plug, at the given setIndex
    :note: use this method to delete your sets instead of manual deletion as it will automatically
        remove the managed partition in case the last set is being deleted"""
    try:
        objset = objectSet(mdplug, setIndex, autoCreate = False)
    except AttributeError:
        # did not exist, its fine
        return
    else:
        # if this is the last set, remove the partition as well
        if len(setsByPlug(mdplug)) == 1:
            setPartition(mdplug, False)
    
        delete(objset)
Esempio n. 6
0
    def deleteObjectSet(self, dataID, setIndex):
        """Delete the object set identified by setIndex
		
		:note: the method is implicitly undoable
		:note: use this method to delete your sets instead of manual deletion as it will automatically
			remove the managed partition in case the last set is being deleted"""
        try:
            objset = self.objectSet(dataID, setIndex, autoCreate=False)
        except (ValueError, AttributeError):
            # did not exist, its fine
            return
        else:
            # if this is the last set, remove the partition as well
            if len(self.setsByID(dataID)) == 1:
                self.setPartition(dataID, False)

            delete(objset)
Esempio n. 7
0
	def deleteObjectSet( self, dataID, setIndex ):
		"""Delete the object set identified by setIndex
		
		:note: the method is implicitly undoable
		:note: use this method to delete your sets instead of manual deletion as it will automatically
			remove the managed partition in case the last set is being deleted"""
		try:
			objset = self.objectSet( dataID, setIndex, autoCreate = False )
		except ( ValueError, AttributeError ):
			# did not exist, its fine
			return
		else:
			# if this is the last set, remove the partition as well
			if len( self.setsByID( dataID ) ) == 1:
				self.setPartition( dataID, False )

			delete( objset )
Esempio n. 8
0
    def setPartition(self, dataID, state):
        """Make all sets in dataID use a partition or not
		
		:param dataID: id identifying the storage plug
		:param state: if True, a partition will be used, if False, it will be disabled
		:note: this method makes sure that all sets are hooked up to the partition
		:raise ValueError: If we did not have a single set to which to add to the partition
		:raise AttributeError: If the dataID has never had sets
		:return: if state is True, the name of the possibly created ( or existing ) partition"""
        sets = self.setsByID(dataID)
        partition = self.partition(dataID)

        if state:
            if partition is None:
                if not sets:
                    raise ValueError(
                        "Cannot create partition as data %r did not have any connected sets"
                        % dataID)
                # END check sets exist
                # create partition
                partition = createNode("storagePartition",
                                       "partition",
                                       forceNewLeaf=True)

                tattr = api.MFnTypedAttribute()
                attr = tattr.create(self._partitionIdAttr, "pid",
                                    api.MFnData.kString)
                partition.addAttribute(attr)
            # END create partition

            # make sure all sets are members of our partition
            partition.addSets(sets)
            return partition
        else:
            if partition:
                # delete partition
                # have to clear partition as, for some reason, or own node will be killed as well !
                partition.clear()
                delete(partition)
Esempio n. 9
0
def delete(devID, token):
    payload = base.build_device_payload(devID=devID, token=token)
    ret = base.delete(url, headers, payload)

    return ret
Esempio n. 10
0
def delete(username, token):
  payload = base.build_payload(username=username, token=token)
  ret = base.delete(url, headers, payload) 

  return ret