Ejemplo n.º 1
0
    def saveTree(self):
        tmpFile = "sharedSourceBackup_" + dateStamp()
        S = SharedSourceTree2XMLFile(tmpFile, self.treeModel.rootItem)

        fileName = QtGui.QFileDialog.getSaveFileName(self, "Path_to_", Path.config("treeBackup"))

        if not moveFile(Path.multiPath(Path.tempStruct, "server", tmpFile), QtCore.QString(fileName).toUtf8().data()):
            showHelp = ListingText("MSG: tree not saved.", self)
            showHelp.exec_()
Ejemplo n.º 2
0
	def searchCertificate(self):
		pubKeyPath = Path.config('pubKey.pem')
		prvKeyPath = Path.config('prvKey.pem')
		if not os.path.isfile(pubKeyPath) or not os.path.isfile(prvKeyPath) :
			createCertificate()
		with open(pubKeyPath, 'rb') as f :
			_str = f.read()
			self.servPubKey = _str.encode('utf-8')
		with open(prvKeyPath, 'rb') as f :
			_str = f.read()
			self.servPrvKey = _str.encode('utf-8')
Ejemplo n.º 3
0
 def loadTree(self):
     fileName = QtGui.QFileDialog.getOpenFileName(self, "Path_to_", Path.config("treeBackup"))
     if fileName != "":
         self.Obj.saveTemporaryData()
         if "serverThread" in dir(self.Obj):
             self.Obj.stopServices(True, fileName, "REINIT")
         else:
             self.preInitServer("reINIT:", fileName)
Ejemplo n.º 4
0
	def cleanAbsentParticipantData(self):
		statesList = []
		for item in self.Obj.USERS.values() : statesList.append(item[4]) 
		#print statesList
		for name in os.listdir(Path.Cache) :
			if name not in statesList :
				if os.path.isfile(Path.cache(name)) : os.remove(Path.cache(name))
				if os.path.isfile(Path.avatar(name)) : os.remove(Path.avatar(name))
				if os.path.isfile(Path.tempCache(name)) : os.remove(Path.tempCache(name))
				if os.path.isfile(Path.tempAvatar(name)) : os.remove(Path.tempAvatar(name))
Ejemplo n.º 5
0
	def filePrepare(self):
		self.doc.appendChild(self.treeSharedDataToXML(self.rootItem))

		#print self.doc.toprettyxml()
		try :
			fileName = Path.multiPath(Path.tempStruct, 'server', self.fileName)
			with open(fileName, 'wb') as f :
				#f.write(doc.toprettyxml())   ## без доп параметров неправильно отображает дерево
				self.doc.writexml(f, encoding = 'utf-8')
			#with open(fileName, 'rb') as f :
			#	print 'Create item File %s :\n%s\n---END---\n' % (fileName, f.read())
		except UnicodeError , err:
			print '[SharedSourceTree2XMLFile.filePrepare() : File not saved]', err
Ejemplo n.º 6
0
	def setMaskSet(self):
		path_ = Path.multiPath(Path.tempStruct, 'client', self.nameMaskFile)
		if not os.path.isfile(path_) :
			print '  file not exist'
			return None
		with open(path_) as f :
			for line in f :
				s = line.split('<||>')
				if s[0] == '1' :
					self.maskSet[int(unicode(str(s[3].decode('utf-8')).replace('\n', '')))] = \
												(int(unicode(str(s[0].decode('utf-8')).replace('\n', ''))), \
												s[1].decode('utf-8'), \
												int(unicode(str(s[2].decode('utf-8')).replace('\n', ''))), \
												int(unicode(str(s[3].decode('utf-8')).replace('\n', ''))))
					#print self.maskSet[int(unicode(str(s[3].decode('utf-8')).replace('\n', '')))]

		os.remove(path_)