コード例 #1
0
ファイル: xmlfiles.py プロジェクト: Ashaman-/pyaimt
def doSpoolPrepCheck():
	pre = os.path.abspath(config.spooldir) + X + config.jid + X

	print "Checking spool files and stringprepping any if necessary...",

	for file in os.listdir(pre):
		if os.path.isfile(pre + file) and file.find(".xml") != -1:
			file = utils.unmangle(file).decode("utf-8", "replace")
			try:
				filej = internJID(file).full()
			except InvalidFormat, UnicodeDecodeError:
				print "Unable to stringprep "+file+".  Putting into BAD directory."
				file = utils.mangle(file)
				if not os.path.isdir(pre + "BAD"):
					os.makedirs(pre + "BAD")
				shutil.move(pre + file, pre + "BAD" + X + file)
				continue
			if file != filej:
				file = utils.mangle(file)
				filej = utils.mangle(filej)
				if os.path.exists(filej):
					print "Need to move "+file+" to "+filej+" but the latter exists!\nAborting!"
					sys.exit(1)
				else:
					shutil.move(pre + file, pre + filej)
コード例 #2
0
def doSpoolPrepCheck():
    pre = os.path.abspath(config.spooldir) + X + config.jid + X

    print "Checking spool files and stringprepping any if necessary...",

    for file in os.listdir(pre):
        if os.path.isfile(pre + file) and file.find(".xml"):
            file = utils.unmangle(file).decode("utf-8", "replace")
            try:
                filej = internJID(file).full()
            except InvalidFormat, UnicodeDecodeError:
                print "Unable to stringprep " + file + ".  Putting into BAD directory."
                file = utils.mangle(file)
                if not os.path.isdir(pre + "BAD"):
                    os.makedirs(pre + "BAD")
                shutil.move(pre + file, pre + "BAD" + X + file)
                continue
            if file != filej:
                file = utils.mangle(file)
                filej = utils.mangle(filej)
                if os.path.exists(filej):
                    print "Need to move " + file + " to " + filej + " but the latter exists!\nAborting!"
                    sys.exit(1)
                else:
                    shutil.move(pre + file, pre + filej)
コード例 #3
0
 def __writeFile(self, file, text):
     file = utils.mangle(file)
     prev_umask = os.umask(SPOOL_UMASK)
     f = open(self.name + X + file + ".xml", "w")
     f.write(text)
     f.close()
     os.umask(prev_umask)
コード例 #4
0
ファイル: legacyaimtransport.py プロジェクト: Ashaman-/pyaimt
	def __writeFile(self, file, text):
		file = utils.mangle(file)
		prev_umask = os.umask(SPOOL_UMASK)
		f = open(self.name + X + file + ".xml", "w")
		f.write(text)
		f.close()
		os.umask(prev_umask)
コード例 #5
0
ファイル: pubsub.py プロジェクト: zfortier/yakalope
    def getNodeList(self, jid):
        """ Retrieves a list of all of the pubsub/pep items for a
		particular jid.  Here we need to hunt through the file system
		and construct Node ids from what we find. """
        nodes = []
        X = os.path.sep
        pubsubbase = os.path.abspath(
            config.spooldir
        ) + X + config.jid + X + "pubsub" + X + utils.mangle(jid)

        if not os.path.isdir(pubsubbase):
            return nodes

        def findfiles(dir=pubsubbase):
            for e in os.listdir(dir):
                if e == "." or e == "..": continue
                path = dir + X + e
                if os.path.isdir(path):
                    findfiles(path)
                elif path.endswith(".xml"):
                    dir = dir.replace(pubsubbase + X, "", 1)
                    if not nodes.count(dir):
                        nodes.append(self.pathToNode(dir))

        findfiles()
        return nodes
コード例 #6
0
 def remove(self, file):
     """ Removes an XDB file """
     file = self.name + X + file[0:2] + X + file + ".xml"
     file = utils.mangle(file)
     try:
         os.remove(file)
     except:
         LogEvent(INFO, msg="XDB error removing file " + file)
         raise
コード例 #7
0
ファイル: legacyjittransport.py プロジェクト: fritteli/pyicqt
	def remove(self, file):
		""" Removes an XDB file """
		file = self.name + X + file + ".xml"
		file = utils.mangle(file)
		try:
			os.remove(file)
		except:
			LogEvent(INFO, msg="XDB error removing file " + file)
			raise
コード例 #8
0
ファイル: legacyjittransport.py プロジェクト: fritteli/pyicqt
	def __writeFile(self, file, text):
		file = utils.mangle(file)
		prev_umask = os.umask(SPOOL_UMASK)
		pre = self.name + X
		if not os.path.exists(pre):
			os.makedirs(pre)
		f = open(pre + file + ".xml", "w")
		f.write(text)
		f.close()
		os.umask(prev_umask)
コード例 #9
0
	def dir(self, jid, node):
		""" Returns the full path to the directory that a 
		particular key is in. Creates that directory if it doesn't already exist. """
		X = os.path.sep
		d = os.path.abspath(config.spooldir) + X + config.jid + X + "pubsub" + X + utils.mangle(jid) + X + self.nodeToPath(node) + X
		prev_umask = os.umask(SPOOL_UMASK)
		if not os.path.exists(d):
			os.makedirs(d)
		os.umask(prev_umask)
		return d
コード例 #10
0
 def __writeFile(self, file, text):
     file = utils.mangle(file)
     prev_umask = os.umask(SPOOL_UMASK)
     pre = self.name + X
     if not os.path.exists(pre):
         os.makedirs(pre)
     f = open(pre + file + ".xml", "w")
     f.write(text)
     f.close()
     os.umask(prev_umask)
コード例 #11
0
ファイル: pubsub.py プロジェクト: zfortier/yakalope
    def dir(self, jid, node):
        """ Returns the full path to the directory that a 
		particular key is in. Creates that directory if it doesn't already exist. """
        X = os.path.sep
        d = os.path.abspath(
            config.spooldir
        ) + X + config.jid + X + "pubsub" + X + utils.mangle(
            jid) + X + self.nodeToPath(node) + X
        prev_umask = os.umask(SPOOL_UMASK)
        if not os.path.exists(d):
            os.makedirs(d)
        os.umask(prev_umask)
        return d
コード例 #12
0
	def getNodeList(self, jid):
		""" Retrieves a list of all of the pubsub/pep items for a
		particular jid.  Here we need to hunt through the file system
		and construct Node ids from what we find. """
		nodes = []
		X = os.path.sep
		pubsubbase = os.path.abspath(config.spooldir)+X+config.jid+X+"pubsub"+X+utils.mangle(jid)

		if not os.path.isdir(pubsubbase):
			return nodes

		def findfiles(dir=pubsubbase):
			for e in os.listdir(dir):
				if e == "." or e == "..": continue
				path=dir+X+e
				if os.path.isdir(path):
					findfiles(path)
				elif path.endswith(".xml"):
					dir = dir.replace(pubsubbase+X,"",1)
					if not nodes.count(dir):
						nodes.append(self.pathToNode(dir))

		findfiles()
		return nodes
コード例 #13
0
 def __getFile(self, file):
     file = utils.mangle(file)
     hash = file[0:2]
     document = utils.parseFile(self.name + X + hash + X + file + ".xml")
     return document
コード例 #14
0
 def __getFile(self, file):
     file = utils.mangle(file)
     document = utils.parseFile(self.name + X + file + ".xml")
     return document
コード例 #15
0
ファイル: legacyjittransport.py プロジェクト: fritteli/pyicqt
	def __getFile(self, file):
		file = utils.mangle(file)
		document = utils.parseFile(self.name + X + file + ".xml")
		return document
コード例 #16
0
ファイル: xmlfiles.py プロジェクト: Ashaman-/pyaimt
	def __getFile(self, file):
		file = utils.mangle(file)
		hash = file[0:2]
		document = utils.parseFile(self.name + X + hash + X + file + ".xml")
		return document