def read_dba(filename, dict_ret=False): buff = '' with open(filename, 'rb') as f: buff = f.read() mylog.debug('buff [%s]' % buff) key = "19465912879oiuxc ensdfaiuo3i73798kjl".encode("US-ASCII") mylog.debug(key) ##decode[i] = ((byte)(buf[i] ^ SQLKeyCode[(i % 36)])); decode = [] s = '' for i in xrange(0, len(buff)): b = ord(buff[i]) ^ ord(key[(i % 36)]) decode.append(b) s += chr(b) mylog.debug(s) s = s.replace('","', '":"').replace('{{', '{').replace('}}', '}').replace('},{', ',') #mylog.debug(s) v = eval(s) #mylog.debug(repr(v)) if dict_ret: return v Server, DB, Login, Password = v["Server"], v["DB"], v["UID"], v["PWD"] mylog.debug(repr([Server, DB, Login, Password])) return Server, DB, Login, Password
def load_folder(self, path): self.base_path = path self.path_md = '' self.path_dba = '' self.db_server, self.db_name, self.db_user, self.db_password = '', '', '', '' if os.path.isdir(self.base_path): mylog.debug(' init from folder: %s' % self.base_path) self.path_md = os.path.join(self.base_path, '1Cv7.MD') self.path_dba = os.path.join(self.base_path, '1Cv7.DBA') if os.path.exists(self.path_md): self.load_1cv7_md(self.path_md) if os.path.exists(self.path_dba): from v7 import dba self.db_server, self.db_name, self.db_user, self.db_password = dba.read_dba(self.path_dba) self.init_db_engine()
def load_folder(self, path): self.base_path = path self.path_md = '' self.path_dba = '' self.db_server, self.db_name, self.db_user, self.db_password = '', '', '', '' if os.path.isdir(self.base_path): mylog.debug(' init from folder: %s' % self.base_path) self.path_md = os.path.join(self.base_path, '1Cv7.MD') self.path_dba = os.path.join(self.base_path, '1Cv7.DBA') if os.path.exists(self.path_md): self.load_1cv7_md(self.path_md) if os.path.exists(self.path_dba): from v7 import dba self.db_server, self.db_name, self.db_user, self.db_password = dba.read_dba( self.path_dba) self.init_db_engine()
def read_dba(filename, dict_ret=False): buff = '' with open(filename, 'rb') as f: buff = f.read() mylog.debug('buff [%s]' % buff) key = "19465912879oiuxc ensdfaiuo3i73798kjl".encode("US-ASCII") mylog.debug(key) ##decode[i] = ((byte)(buf[i] ^ SQLKeyCode[(i % 36)])); decode = [] s = '' for i in xrange(0, len(buff)): b = ord(buff[i]) ^ ord(key[(i%36)]) decode.append( b ) s += chr(b) mylog.debug(s) s = s.replace('","','":"').replace('{{','{').replace('}}','}').replace('},{',',') #mylog.debug(s) v = eval(s) #mylog.debug(repr(v)) if dict_ret: return v Server, DB, Login, Password = v["Server"], v["DB"], v["UID"], v["PWD"] mylog.debug(repr([Server, DB, Login, Password])) return Server, DB, Login, Password
buff = f.read() mylog.debug('buff [%s]' % buff) key = "19465912879oiuxc ensdfaiuo3i73798kjl".encode("US-ASCII") mylog.debug(key) ##decode[i] = ((byte)(buf[i] ^ SQLKeyCode[(i % 36)])); decode = [] s = '' for i in xrange(0, len(buff)): b = ord(buff[i]) ^ ord(key[(i % 36)]) decode.append(b) s += chr(b) mylog.debug(s) s = s.replace('","', '":"').replace('{{', '{').replace('}}', '}').replace('},{', ',') #mylog.debug(s) v = eval(s) #mylog.debug(repr(v)) if dict_ret: return v Server, DB, Login, Password = v["Server"], v["DB"], v["UID"], v["PWD"] mylog.debug(repr([Server, DB, Login, Password])) return Server, DB, Login, Password #{{"Server","192.168.1.30"},{"DB","work"},{"UID","sa"},{"PWD","xxxeral!"},{"Checksum","bf062f4f"}} if __name__ == '__main__': from v7 import getDataPath server, db, user, pwd = read_dba(getDataPath('1Cv7.DBA')) mylog.debug("Server: %s" % server)
buff = '' with open(filename, 'rb') as f: buff = f.read() mylog.debug('buff [%s]' % buff) key = "19465912879oiuxc ensdfaiuo3i73798kjl".encode("US-ASCII") mylog.debug(key) ##decode[i] = ((byte)(buf[i] ^ SQLKeyCode[(i % 36)])); decode = [] s = '' for i in xrange(0, len(buff)): b = ord(buff[i]) ^ ord(key[(i%36)]) decode.append( b ) s += chr(b) mylog.debug(s) s = s.replace('","','":"').replace('{{','{').replace('}}','}').replace('},{',',') #mylog.debug(s) v = eval(s) #mylog.debug(repr(v)) if dict_ret: return v Server, DB, Login, Password = v["Server"], v["DB"], v["UID"], v["PWD"] mylog.debug(repr([Server, DB, Login, Password])) return Server, DB, Login, Password #{{"Server","192.168.1.30"},{"DB","work"},{"UID","sa"},{"PWD","xxxeral!"},{"Checksum","bf062f4f"}} if __name__ == '__main__': from v7 import getDataPath server, db, user, pwd = read_dba(getDataPath('1Cv7.DBA')) mylog.debug("Server: %s" % server)
def __init__(self, base_path=None): mylog.debug('init Application') self.metadata = None self.md = None self.db = None self.load_folder(base_path)
def load_1cv7_md(self,filename): mylog.debug(' load: %s' % filename) self.md = md_reader.parse_md(filename) self.metadata = md_reader.extract_metadata(self.md)
def disconect(self): if self.db: mylog.debug('disconect db') self.db.close()
def connect(self): if self.db: mylog.debug('connect db') self.db.connect()
def init_db_engine(self): if self.db_server: mylog.debug('init MSSQL connection proxy') from v7 import MS_Proxy self.db = MS_Proxy(self.db_name, self.db_server, self.db_user, self.db_password)
def load_1cv7_md(self, filename): mylog.debug(' load: %s' % filename) self.md = md_reader.parse_md(filename) self.metadata = md_reader.extract_metadata(self.md)