In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
#-*-coding:utf-8-*-#! / bin/env python'''#Auth:karl#Function: released version#Date:2017/6/27#Version:V1.0'''import sys,re,time Datetimeimport paramikoimport loggingimport ConfigParserimport tracebackimport MySQLdbimport platformimport xlrdreload (sys) sys.setdefaultencoding ('utf-8') if "Linux" = = platform.system (): Excelpath= "/ home/appdeploy/version/Version" else: Excelpath= "D:\\ auto\\ release\ Version" class Mysql_connect (object): def _ init__ (self) * agre): self.port=agre [0] self.passwd=agre [1] self.username=agre [2] self.host=agre [3] self.version=agre [4] def File_get (self): Excelfilepath= "{path} _ {version} / Filelist.xlsx" .format (path=Excelpath Version=self.version) workbook=xlrd.open_workbook (Excelfilepath) booksheet = workbook.sheet_by_name ('Sheet1') self.p=list () for row in range (booksheet.nrows): row_data = [] for col in range (booksheet.ncols): cel = booksheet.cell (row) Col) val = cel.value try: val = cel.valueval = re.sub (r'\ s subscription,'' Val) except: pass if type (val) = = float: val = int (val) else: val = str (val) row_data.append (val) self.p.append (row_data) self.__ Mysql_deal () def _ _ Mysql_deal (self): try: con = MySQLdb.connect (user=self.username Passwd=self.passwd,db= "version_release", port=int (self.port), charset= "utf8") dt = datetime.datetime.now () .strftime ("% Y-%m-%d% H:%M:%S") cursor=con.cursor () cursor.execute ("CREATE TABLE IF NOT EXISTS version (Id INT PRIMARY KEY AUTO_INCREMENT,\ File VARCHAR (30) DEFAULT null,Release_date TIMESTAMP) Instruction text) ") sql="INSERT INTO version (File,Release_date,Instruction) VALUES (% s,% s)"for value in self.p: valuse= (value [0], dt,value [1]) result=cursor.execute (sql) Valuse) cursor.close () con.commit () con.close () except MySQLdb.Error, e: print "Error% d:% s"% (e.args [0]) E.args [1]) sys.exit (1) def File_deal (self): try: ssh = paramiko.SSHClient () ssh.set_missing_host_key_policy (paramiko.AutoAddPolicy ()) ssh.connect (self.host,22, "root", "*" Timeout=5) for name in self.p: route_0=name [0] route=name [1] cmd= "\ cp-vr {path} _ {version} / {filename} .xls {dir_new}" .format (path=Excelpath,version=self.version,filename=route_0,dir_new=route) stdin, stdout Stderr = ssh.exec_command (cmd) for out_msg in stdout.readlines (): print out_msg except Exception, e: print's\ tError\ n'% (self.host), e ssh.close () def main (): agre = ["3306", "*", "root", "xx.xx.xx.xx" Stg = Mysql_connect (* agre) stg.File_get () stg.File_deal () if _ _ name__ = ='_ _ main__': try: main () except Exception as e: print traceback.format_exc ()
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.