示例#1
0
 def files(self):
     """ Returns a list containing the files in the current XDB database """
     files = os.listdir(self.name)
     for i in range(len(files)):
         files[i] = utils.unmangle(files[i])
         files[i] = files[i][:len(files[i]) - 4]
     return files
示例#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 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)
示例#4
0
	def files(self):
		""" Returns a list containing the files in the current XDB database """         
		files=os.listdir(self.name);
		for i in range(len(files)):
			files[i]=utils.unmangle(files[i])
			files[i]=files[i][:len(files[i])-4]
		return files
示例#5
0
	def files(self):
		""" Returns a list containing the files in the current XDB database """
		files = []
		files.extend(os.listdir(self.name))
		files = [utils.unmangle(x) for x in files]
		files = [x[:-4] for x in files]
		while files.count(''):
			files.remove('')

		return files
示例#6
0
    def files(self):
        """ Returns a list containing the files in the current XDB database """
        files = []
        files.extend(os.listdir(self.name))
        files = [utils.unmangle(x) for x in files]
        files = [x[:-4] for x in files]
        while files.count(''):
            files.remove('')

        return files
示例#7
0
    def files(self):
        """ Returns a list containing the files in the current XDB database """
        files = []
        for dir in os.listdir(self.name):
            if len(dir) != 2: continue
            if os.path.isdir(self.name + X + dir):
                files.extend(os.listdir(self.name + X + dir))
        files = [utils.unmangle(x) for x in files]
        files = [x[:-4] for x in files]
        while files.count(''):
            files.remove('')

        return files
示例#8
0
	def files(self):
		""" Returns a list containing the files in the current XDB database """
		files = []
		for dir in os.listdir(self.name):
			if len(dir) != 2: continue
			if os.path.isdir(self.name + X + dir):
				files.extend(os.listdir(self.name + X + dir))
		files = [utils.unmangle(x) for x in files]
		files = [x[:-4] for x in files]
		while files.count(''):
			files.remove('')

		return files
示例#9
0
def doSpoolFormatChange():
	pre = os.path.abspath(config.spooldir) + X + config.jid + X
	myxdb = XDB(config.jid)

	print "Checking spool files and adjusting format if necessary..."

	for dir in os.listdir(pre):
		if os.path.isdir(pre + dir):
			for file in os.listdir(pre + dir):
				if os.path.isfile(pre + dir + X + file):
					# First lets pull information from the old format
					jabberid = utils.unmangle(file[:file.find('.xml')])
					base = myxdb.request(jabberid, "aimtrans:data")
					if base == None:
						# This one is probably already in the new format.
						print "   %s seems to be fine" % jabberid
						continue

					username = ""
					password = ""

					for child in base.elements():
						try:
							if child.name == "logon":
								username = child.getAttribute("id")
							if child.getAttribute("encpass"):
								password = utils.decryptPassword(child.getAttribute("encpass"))
							else:
								password = child.getAttribute("pass")
						except AttributeError:
							continue

					# Lets get the roster for future use
					roster = myxdb.request(jabberid, "aimtrans:roster")

					# Now ditch the old entry
					myxdb.remove(jabberid)

					if username == "" and password == "":
						# Well, bye.. if this person doesn't have a username and password then what use is the registration
						print "   Removing %s because it doesn't have a username and/or password" % jabberid
						continue

					print "   Converting %s to new spool format..." % jabberid

					# Ok, this appears to be a good account but in the old format, lets create it in the new format
					myxdb.setRegistration(jabberid,username,password)

					if roster == None:
						# Doesn't appear to have a roster, no big deal, move on
						print "   [Just FYI, %s doesn't have a roster]" % jabberid
						continue

					# Lets add all their roster elements individually!
					for child in roster.elements():
						try:
							if child.name == "buddies":
								for item in child.elements():
									try:
										if(item.name == "item"):
											myxdb.setListEntry("roster", jabberid, item.getAttribute("name"))
									except AttributeError:
										continue
						except AttributeError:
							continue

	print "...done"
示例#10
0
def doSpoolFormatChange():
	pre = os.path.abspath(config.spooldir) + X + config.jid + X
	myxdb = XDB(config.jid)

	print "Checking spool files and adjusting format if necessary..."

	for dir in os.listdir(pre):
		if os.path.isdir(pre + dir):
			for file in os.listdir(pre + dir):
				if os.path.isfile(pre + dir + X + file):
					# First lets pull information from the old format
					jabberid = utils.unmangle(file[:file.find('.xml')])
					base = myxdb.request(jabberid, "aimtrans:data")
					if base == None:
						# This one is probably already in the new format.
						print "   %s seems to be fine" % jabberid
						continue

					username = ""
					password = ""

					for child in base.elements():
						try:
							if child.name == "logon":
								username = child.getAttribute("id")
							if child.getAttribute("encpass"):
								password = utils.decryptPassword(child.getAttribute("encpass"))
							else:
								password = child.getAttribute("pass")
						except AttributeError:
							continue

					# Lets get the roster for future use
					roster = myxdb.request(jabberid, "aimtrans:roster")

					# Now ditch the old entry
					myxdb.remove(jabberid)

					if username == "" and password == "":
						# Well, bye.. if this person doesn't have a username and password then what use is the registration
						print "   Removing %s because it doesn't have a username and/or password" % jabberid
						continue

					print "   Converting %s to new spool format..." % jabberid

					# Ok, this appears to be a good account but in the old format, lets create it in the new format
					myxdb.setRegistration(jabberid,username,password)

					if roster == None:
						# Doesn't appear to have a roster, no big deal, move on
						print "   [Just FYI, %s doesn't have a roster]" % jabberid
						continue

					# Lets add all their roster elements individually!
					for child in roster.elements():
						try:
							if child.name == "buddies":
								for item in child.elements():
									try:
										if(item.name == "item"):
											myxdb.setListEntry("roster", jabberid, item.getAttribute("name"))
									except AttributeError:
										continue
						except AttributeError:
							continue

	print "...done"