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_()
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')
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)
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))
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
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_)