示例#1
0
def do(message,filename):
	FileUtil.if_has_file_remove(filename)
	output = FileUtil.open(filename,"w")
	output.write(sign(message))
	output.close()
	input = FileUtil.open(filename,"r")
	ok = verify(message,input.read())
	input.close()
	return ok
	def update(self):
		print 'Checking for new update...'
		versionfile = self.netopen('/'+common.CONFIG_VERSIONFILE)
		print "Show Server Version Message:"
		print versionfile
		oldsha1 = self.old_file_sha1_ini
		path = common.CONFIG_SHA1+'.tmp'
		FileUtil.if_has_file_remove(path)
		self.getnewsha1(path,oldsha1)
		newsha1 = Config(path)
		for path, sha1v in newsha1.getsection('FILE_SHA1'):
			if not (sha1v == oldsha1.getconfig('FILE_SHA1',path)):
				oldpath = path
				path = path.replace('$path$','')
				path = path.replace('\\','/')
				self.writefile(path,sha1v)
		FileUtil.if_has_file_remove(path)
		print 'Finished Update'
		print 'Cleaning DIR'
		self.cleandir()
		print 'Finished Clean'
示例#3
0
文件: autoupdate.py 项目: droided/wp
 def update(self):
     print "Checking for new update..."
     versionfile = self.netopen("/" + common.CONFIG_VERSIONFILE)
     print "Show Server Version Message:"
     print versionfile
     oldsha1 = self.old_file_sha1_ini
     path = common.CONFIG_SHA1 + ".tmp"
     FileUtil.if_has_file_remove(path)
     self.getnewsha1(path, oldsha1)
     newsha1 = Config(path)
     for path, sha1v in newsha1.getsection("FILE_SHA1"):
         if not (sha1v == oldsha1.getconfig("FILE_SHA1", path)):
             oldpath = path
             path = path.replace("$path$", "")
             path = path.replace("\\", "/")
             self.writefile(path, sha1v)
     FileUtil.if_has_file_remove(path)
     print "Finished Update"
     print "Cleaning DIR"
     self.cleandir()
     print "Finished Clean"
def makehash(dir,topdown=True):
	try : 
		print 'Generating '+common.CONFIG_SHA1+' table...'
		FileUtil.if_has_file_remove(common.CONFIG_SHA1)
		sha1 = Config(common.CONFIG_SHA1)
		for root, dirs, files in os.walk(dir, topdown):
			for name in files:
				path = os.path.join(root,name)
				newpath = path.replace(dir,'$path$')
				regexpath = path.replace(dir,'.')
				if regexpath.startswith(common.REGEX_START) or regexpath.endswith(common.REGEX_END):
					continue
				else:
					sha1v = FileUtil.sumfile(path)
					sha1.writeconfig('FILE_SHA1',newpath,sha1v)
		print 'DONE generate '+common.CONFIG_SHA1+' table!'
		return sha1
	except Exception as e:
		print 'FAIL to generate '+common.CONFIG_SHA1+' table!'
		print e
		sys.exit()
示例#5
0
def makehash(dir, topdown=True):
    try:
        print 'Generating ' + common.CONFIG_SHA1 + ' table...'
        FileUtil.if_has_file_remove(common.CONFIG_SHA1)
        sha1 = Config(common.CONFIG_SHA1)
        for root, dirs, files in os.walk(dir, topdown):
            for name in files:
                path = os.path.join(root, name)
                newpath = path.replace(dir, '$path$')
                regexpath = path.replace(dir, '.')
                if regexpath.startswith(
                        common.REGEX_START) or regexpath.endswith(
                            common.REGEX_END):
                    continue
                else:
                    sha1v = FileUtil.sumfile(path)
                    sha1.writeconfig('FILE_SHA1', newpath, sha1v)
        print 'DONE generate ' + common.CONFIG_SHA1 + ' table!'
        return sha1
    except Exception as e:
        print 'FAIL to generate ' + common.CONFIG_SHA1 + ' table!'
        print e
        sys.exit()
	def cleandir(self):
		needclean = Config(common.CONFIG_NEEDCLEAN)
		for path, sha1v in needclean.getsection('NEEDCLEAN'):
			path = path.replace('\\','/')
			path = path.replace('$path$/','')
			FileUtil.if_has_file_remove(path,showinfo = True)
示例#7
0
文件: autoupdate.py 项目: droided/wp
 def cleandir(self):
     needclean = Config(common.CONFIG_NEEDCLEAN)
     for path, sha1v in needclean.getsection("NEEDCLEAN"):
         path = path.replace("\\", "/")
         path = path.replace("$path$/", "")
         FileUtil.if_has_file_remove(path, showinfo=True)