def org_mate(self, org, file_name, ver, file_path):
     with open("D:\python\monitor_files\org.txt",
               mode='r',
               encoding='utf-8') as f:
         orglist = f.readlines()
     with open("D:\\python\\monitor_files\\version.txt",
               mode='r',
               encoding='utf-8') as g:
         verlist = g.readlines()
         #print(ftextlist)
         for org_list in orglist:
             org_list = org_list.split(" ")
             for ver_list in verlist:
                 ver_list = ver_list.split(" ")
                 print(org_list[0], org, ver_list[0], ver)
                 if org_list[0] == org and ver_list[0] == ver:
                     orgmail = org_list[2]
                     big_ver = ver_list[1]
                     sml_ver = ver_list[2]
                     Sendmail.Sendmail(orgmail, file_name, big_ver, sml_ver,
                                       file_path)
                     print(orgmail)
                     print(file_name)
                 else:
                     pass
def down_server(filename,ip,user,pwd,remove_dir,local_dir):
    try:    
	ftp = FTP()
    	ftp.set_debuglevel(2)
    	ftp.connect(ip,'21')
    	ftp.login(user,pwd)
	ftp.cwd(remove_dir)
    	bufsize = 1024
    	file_handler = open(filename,'wb').write
    	ftp.retrbinary('RETR %s'%os.path.basename(filename),file_handler,bufsize)
    	ftp.set_debuglevel(0)
    	ftp.quit()
    except EOFError:
	ftp.close()
	Sendmail.sendmail(ip + 'backup FAILED,error:' + EOFError)
    move_cmd = 'mv ' + filename + ' ' +  local_dir 
    os.system(move_cmd)
def down_SW(filename,ip,user,pwd,sys_name):
    try:    
	ftp = FTP()
    	ftp.set_debuglevel(2)
    	ftp.connect(ip,'21')
    	ftp.login(user,pwd)
    	bufsize = 1024
    	file_handler = open(filename,'wb').write
    	ftp.retrbinary('RETR %s'%os.path.basename(filename),file_handler,bufsize)
    	ftp.set_debuglevel(0)
    	ftp.close()
    except EOFError:
	ftp.close()
	Sendmail.sendmail(sys_name + 'backup FAILED,error:' + EOFError)
    filename = '%sstartup%s.cfg'%(sys_name,time.strftime('%Y-%m-%d'))
    os.system('mv startup.cfg net_config/startup.cfg')
    os.chdir('net_config')
    os.rename('startup.cfg',filename)
    os.chdir('..')
Beispiel #4
0
def compile(env,tagname,jsonstr):
    global workpath
    global username
    global pwd
    global push
    global ret
    global sourcedir 
    logger=log.getlogger()
    logger.info(os.getcwd())
    logger.info(jsonstr)
    if env=='.net':
        try:
            exportfile(jsonstr,'trunk')
            getprojfilepath()
            print ret
            logger.info(ret)
            os.chdir(ret)
            l=sourcedir.split('/')
            projname=l[len(l)-2]
            if push==0:
                cmd='msbuild /p:Configuration=Release;VisualStudioVersion=12.0 /p:WebProjectOutputDir=%s\\192.168.10.62\\upload\\%s /p:OutputPath=%s\\192.168.10.62\\upload\\%s\\bin'%('\\',projname,'\\',projname) 
            if push==1:
                cmd='msbuild /p:Configuration=Release;VisualStudioVersion=12.0'
            print cmd
            res=os.system(cmd)
            if push==0:
                cmd='msbuild /p:Configuration=Release;VisualStudioVersion=12.0 /p:WebProjectOutputDir=c:\\Release\\%s /p:OutputPath=c:\\Release\\%s\\bin'%(projname,projname) 
                os.system(cmd)
                cmd='msbuild /p:Configuration=Release;VisualStudioVersion=12.0'
                os.system(cmd)
            if res==0:              
                r=svn.remote.RemoteClient(sourcedir,username,pwd)
                files=svndiff.showdiff(sourcedir+'/tags/original',workpath)  
                winupload.winup(0,'\\192.168.10.62\\upload\\backup', files, projname,tagname)
                winupload.winup(1,'c:\\zz',files,projname,tagname)
                sshupload.uploadfile(projname, files, '172.18.7.88', '/home/swift/','swift', '1234qwer')
                path=['trunk','tags/'+tagname]
                print r.run_command('copy',[sourcedir+'trunk', sourcedir+'tags/'+tagname+'_compiled','-m','copy'])
                dbclient=mongodbaction()
                dbclient.insertlog(projname,username,'compile',tagname)        
                if push==0:
                    Sendmail.sendtogroup('test', 'version '+tagname, 'version '+tagname+' is compiled,please test..'+'path : '+sourcedir+"/tags/"+tagname.encode()+'_compiled')
                Sendmail.sendtogroup('develop', 'version '+tagname, 'version '+tagname+' is compiled successfully..'+'path : '+sourcedir+"/tags/"+tagname.encode()+'_compiled')
                return 'success'
            else:
                Sendmail.sendtogroup('develop', 'version '+tagname, 'version '+tagname+' is compiled failed..')
                return 'failed'
        except Exception,e:
            print e
            return e
Beispiel #5
0
def backup_config():
    today_time = time.strftime("%Y%m%d")
    if not os.path.exists(today_time):
        os.mkdir(today_time)
    Ftpmkdir.ftp_mkdir_date(today_time)
    file = open("SwitchConfig.json", "rb")
    fileJson = json.load(file)
    switch = fileJson["switch"]
    backFileMode = fileJson["backFileMode"]
    #备份文件
    for i in range(len(switch)):
        print switch[i]
        if switch[i]["protocol"] == "ssh":
            if switch[i].has_key('isNeedSecondaryConfirmation') and switch[i][
                    "isNeedSecondaryConfirmation"] == "1":
                result = sshconfig(switch[i]["ip"], switch[i]["port"],
                                   switch[i]["username"],
                                   switch[i]["password"],
                                   switch[i]["ftpserver"],
                                   switch[i]["ftpuser"],
                                   switch[i]["ftppasswd"], today_time)
            else:
                result = sshconfig(switch[i]["ip"], switch[i]["port"],
                                   switch[i]["username"],
                                   switch[i]["password"],
                                   switch[i]["ftpserver"],
                                   switch[i]["ftpuser"],
                                   switch[i]["ftppasswd"], today_time)
        source_ip_list = []
        source_ip_list.append(switch[i]["ip"])
    print source_ip_list
    ftp_ip_list(switch[i]["ftpserver"], switch[i]["ftpuser"],
                switch[i]["ftppasswd"], today_time)
    readIp(today_time)
    #compare(source_ip_list,results_ip_list,today_time)
    diff_ip = set(source_ip_list).difference(set(results_ip_list))
    #os.remove('%s/compare_ip.txt' %today_time)
    with open('%s/compare_ip.txt' % today_time, 'a+') as z:
        z.write(str(diff_ip))
        z.closed
    Sendmail.Sendmail()
Beispiel #6
0
         else:
             Sendmail.sendtogroup('develop', 'version '+tagname, 'version '+tagname+' is compiled failed..')
             return 'failed'
     except Exception,e:
         print e
         return e
 if env=='java':
     exportfile(jsonstr,'trunk')
     os.chdir(workpath)
     res=os.system('ant')
     if res==0:
         l=sourcedir.split('/')
         projname=l[len(l)-2]
         files=svndiff.showdiff(sourcedir+'/trunk',workpath)
         sshupload.uploadfile(projname,files, '192.168.10.166','/home/swift/addtional/', 'swift', 'wjffsxka')
         Sendmail.sendtogroup('testing', 'version '+tagname, 'version '+tagname+' is compiled,please test..'+'path : '+sourcedir+"/tags/"+tagname.encode()+'_compiled'+'server path is '+'/home/swift')
         Sendmail.sendtogroup('develop', 'version '+tagname, 'version '+tagname+' is compiled successfully..'+'path : '+sourcedir+"/tags/"+tagname.encode()+'_compiled')
         #shutil.rmtree(workpath, True)
         return 'success'
     else:
         Sendmail.sendtogroup('develop', 'version '+tagname, 'version '+tagname+' is compiled failed..')
         #shutil.rmtree(workpath, True)
         return 'failed'
 if env=='testok':
     ssdir=jsondecode.jsondecode(jsonstr,'svnurl') 
     l=ssdir.split('/')
     projname=l[len(l)-2]    
     Sendmail.sendtogroup('run', 'version '+tagname, 'project:'+projname+' version: '+tagname+' is test ok,please pull it')
     dbclient=mongodbaction()
     dbclient.insertlog(projname,jsondecode.jsondecode(jsonstr,'username'),'test ok',tagname)
 if env=='run':
Beispiel #7
0
import time

user = '******'
passwd = 'CooTek123'
mysqlcmd = '/usr/bin/mysqldump'
gzipcmd = '/bin/gzip'
mysqldb = ['zabbix',]
tobakdir = '/data/mysql_backup/'
now_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time()))
#backup mysql database
for db in mysqldb:
    backfile = tobakdir + db + '-' + time.strftime('%Y-%m-%d') + '.sql'
    gzfile = backfile + '.gz'
    if os.path.isfile(gzfile):
        print now_time +'\n' + gzfile + 'is already backup!'
	Sendmail.sendmail(now_time +'\n' + gzfile + 'is already backup')	
    else:
        back_cmd = mysqlcmd + ' -u' + user + ' -p' + passwd + ' ' + db + ' >' + backfile
	if os.system(back_cmd)==0:
            print now_time +'\n' + 'Success backup to', db +  'to' + backfile
	    Sendmail.sendmail(now_time +'\n' + 'Successful backup to'+ backfile)
            gzip_cmd = gzipcmd + ' ' + backfile
            if os.system(gzip_cmd)==0:
                print now_time +'\n' + 'Successful Gzip to',gzfile
	        Sendmail.sendmail(now_time +'\n' + 'Successful backup and gzip to'+ gzfile)
            else:
                print now_time +'\n' + 'Gzip FAILED!!!'
	        Sendmail.sendmail(now_time +'\n' + 'Gzip FAILED!!!')
        else:
            print now_time +'\n' + 'Backup FAILED!!!'
	    Sendmail.sendmail(now_time +'\n' + 'Backup FAILED!!!')
Beispiel #8
0
        stock_index.loc[item[0], 'position'] = position  # 自动往下填充的就是上一个产生的交易信号;关键;
    # 计算股票每日收益率
    stock_index['pct_change'] = stock_index['Close'].pct_change()
    # 计算股票的累积收益率
    stock_index['return'] = (stock_index['pct_change'] + 1).cumprod()
    # 计算策略每日收益率
    stock_index['strategy_return'] = stock_index['position'] * stock_index['pct_change']
    # 计算策略累积收益率
    stock_index['cum_strategy_return'] = (stock_index['strategy_return'] + 1).cumprod()

    signalsheeti = stock_index[['Date','signal','position','return','cum_strategy_return']]
    signalsheeti.insert(0, 'symbol', sheet_name)
    signalsheeti.to_excel(excel_writer=writer, sheet_name=sheet_name,encoding="utf-8", index=True)

    if signalsheeti.iloc[-1:].signal.values==1 :
        addlist=pd.DataFrame(signalsheeti.iloc[-1:])
        if todaylist is None :
            todaylist= addlist
        else :
            todaylist=todaylist.append(addlist,ignore_index=True)


    print('Save ' + sheet_name + ' Complete!')

writer.save()
writer.close()

Sendmail.send_email(u"*****@*****.**",u"*****@*****.**",u"今日挤牌",u"xxx",todaylist.to_html())
Sendmail.send_email(u"*****@*****.**",u"*****@*****.**",u"今日挤牌",u"xxx",todaylist.to_html())

def on_created(event):
    msg = f"{event.src_path} has been Generated.\n Please Have a look!!"  #Body of the mail
    Sendmail.sendMail(msg)
Beispiel #10
0
t=open(dest_ys_path,'w')

for url in config_url_list:
    txt=session.get(url)
    content1=txt.content
    #print content1
    contents=re.findall(r'<div class=\\"WB_text.*\\" node-type=\\"feed_list_content\\" nick-name=\\"\S+>.*?<\\/div>',content1)
    content="".join(contents)
    contentnostart=re.sub(r'<div class=\\"WB_text.*\\" node-type=\\"feed_list_content\\" nick-name=\\"\S+>\\n\s+','',content)
    contentnoend=re.sub(r'\s+<\\/div>',writeStr+writeStr,contentnostart)
    t.write(contentnoend+writeStr+writeStr)

t.close()   
config_url.close()

    


Sendmail.sendmail(dest_mw_path,dest_ms_path,dest_yer_path,dest_ys_path)










Beispiel #11
0
user = '******'
passwd = 'CooTek123'
mysqlcmd = '/usr/bin/mysqldump'
gzipcmd = '/bin/gzip'
mysqldb = [
    'zabbix',
]
tobakdir = '/data/mysql_backup/'
now_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
#backup mysql database
for db in mysqldb:
    backfile = tobakdir + db + '-' + time.strftime('%Y-%m-%d') + '.sql'
    gzfile = backfile + '.gz'
    if os.path.isfile(gzfile):
        print now_time + '\n' + gzfile + 'is already backup!'
        Sendmail.sendmail(now_time + '\n' + gzfile + 'is already backup')
    else:
        back_cmd = mysqlcmd + ' -u' + user + ' -p' + passwd + ' ' + db + ' >' + backfile
        if os.system(back_cmd) == 0:
            print now_time + '\n' + 'Success backup to', db + 'to' + backfile
            Sendmail.sendmail(now_time + '\n' + 'Successful backup to' +
                              backfile)
            gzip_cmd = gzipcmd + ' ' + backfile
            if os.system(gzip_cmd) == 0:
                print now_time + '\n' + 'Successful Gzip to', gzfile
                Sendmail.sendmail(now_time + '\n' +
                                  'Successful backup and gzip to' + gzfile)
            else:
                print now_time + '\n' + 'Gzip FAILED!!!'
                Sendmail.sendmail(now_time + '\n' + 'Gzip FAILED!!!')
        else:
Beispiel #12
0
def compile(env, tagname, jsonstr):
    global workpath
    global username
    global pwd
    global push
    global ret
    global sourcedir
    logger = log.getlogger()
    logger.info(os.getcwd())
    logger.info(jsonstr)
    if env == '.net':
        try:
            exportfile(jsonstr, 'trunk')
            getprojfilepath()
            print ret
            logger.info(ret)
            os.chdir(ret)
            l = sourcedir.split('/')
            projname = l[len(l) - 2]
            if push == 0:
                cmd = 'msbuild /p:Configuration=Release;VisualStudioVersion=12.0 /p:WebProjectOutputDir=%s\\192.168.10.62\\upload\\%s /p:OutputPath=%s\\192.168.10.62\\upload\\%s\\bin' % (
                    '\\', projname, '\\', projname)
            if push == 1:
                cmd = 'msbuild /p:Configuration=Release;VisualStudioVersion=12.0'
            print cmd
            res = os.system(cmd)
            if push == 0:
                cmd = 'msbuild /p:Configuration=Release;VisualStudioVersion=12.0 /p:WebProjectOutputDir=c:\\Release\\%s /p:OutputPath=c:\\Release\\%s\\bin' % (
                    projname, projname)
                os.system(cmd)
                cmd = 'msbuild /p:Configuration=Release;VisualStudioVersion=12.0'
                os.system(cmd)
            if res == 0:
                r = svn.remote.RemoteClient(sourcedir, username, pwd)
                files = svndiff.showdiff(sourcedir + '/tags/original',
                                         workpath)
                winupload.winup(0, '\\192.168.10.62\\upload\\backup', files,
                                projname, tagname)
                winupload.winup(1, 'c:\\zz', files, projname, tagname)
                sshupload.uploadfile(projname, files, '172.18.7.88',
                                     '/home/swift/', 'swift', '1234qwer')
                path = ['trunk', 'tags/' + tagname]
                print r.run_command('copy', [
                    sourcedir + 'trunk',
                    sourcedir + 'tags/' + tagname + '_compiled', '-m', 'copy'
                ])
                dbclient = mongodbaction()
                dbclient.insertlog(projname, username, 'compile', tagname)
                if push == 0:
                    Sendmail.sendtogroup(
                        'test', 'version ' + tagname, 'version ' + tagname +
                        ' is compiled,please test..' + 'path : ' + sourcedir +
                        "/tags/" + tagname.encode() + '_compiled')
                Sendmail.sendtogroup(
                    'develop', 'version ' + tagname, 'version ' + tagname +
                    ' is compiled successfully..' + 'path : ' + sourcedir +
                    "/tags/" + tagname.encode() + '_compiled')
                return 'success'
            else:
                Sendmail.sendtogroup(
                    'develop', 'version ' + tagname,
                    'version ' + tagname + ' is compiled failed..')
                return 'failed'
        except Exception, e:
            print e
            return e
Beispiel #13
0
     except Exception, e:
         print e
         return e
 if env == 'java':
     exportfile(jsonstr, 'trunk')
     os.chdir(workpath)
     res = os.system('ant')
     if res == 0:
         l = sourcedir.split('/')
         projname = l[len(l) - 2]
         files = svndiff.showdiff(sourcedir + '/trunk', workpath)
         sshupload.uploadfile(projname, files, '192.168.10.166',
                              '/home/swift/addtional/', 'swift', 'wjffsxka')
         Sendmail.sendtogroup(
             'testing', 'version ' + tagname,
             'version ' + tagname + ' is compiled,please test..' +
             'path : ' + sourcedir + "/tags/" + tagname.encode() +
             '_compiled' + 'server path is ' + '/home/swift')
         Sendmail.sendtogroup(
             'develop', 'version ' + tagname, 'version ' + tagname +
             ' is compiled successfully..' + 'path : ' + sourcedir +
             "/tags/" + tagname.encode() + '_compiled')
         #shutil.rmtree(workpath, True)
         return 'success'
     else:
         Sendmail.sendtogroup(
             'develop', 'version ' + tagname,
             'version ' + tagname + ' is compiled failed..')
         #shutil.rmtree(workpath, True)
         return 'failed'
 if env == 'testok':
Beispiel #14
0
#dfPivot.sort_values(by=('LAST_TASK', 'All'), ascending=False,inplace=True)
writer = pd.ExcelWriter(default+"Backlog\\"+day+"_"+month+".xlsx",engine = 'xlsxwriter')
Backlog.to_excel(writer,'Sheet1',index = False)
dfPivot.to_excel(writer,'Sheet2',index = True)
writer.save()
saveExcel(default+"Main.xlsx",'Sheet1',dfMain)
Dict = PrintStatements(dfMain)
Dict['Date'] = coldate + timedelta(days=1) 
for keys,values in Dict.items():
    print(keys ,":",values)
#print(pd.crosstab(dfMain["TEAM"],dfMain["AgeReq"],margins=True))
TO = '[email protected]; [email protected];[email protected];[email protected]; [email protected];[email protected]; [email protected];[email protected]'
#TO = '*****@*****.**'
triage = 'C:\\Users\\prerna.prakash\\Desktop\\Input\\TriageSheet\\'
attch = [default+"Backlog\\"+day+"_"+month+".xlsx",triage+'BillingTriage.xlsx',triage+'ExternalTriage.xlsx',triage+'OSMTriage.xlsx',triage+'UIMTriage.xlsx']
sm.send_Mail(TO,'12+ Status',attch,html)
#print(dfMain.groupby("LAST_TASK").filter(lambda x :x['LAST_TASK'].aggregate("count") > 4))

save = input("DO you want to save this data?")
if save == ('y') :

  
    dfSaver = pd.DataFrame(data=Dict,index = [0])  
    dfsaveit = pd.read_excel("C:\\Users\\prerna.prakash\\Desktop\\Input\\AgeDataNew.xlsx","Sheet1")

#dfsaveit =dfsaveit.append(dfSaver)
    dfsaveit = pd.concat([pd.DataFrame(dfSaver), dfsaveit], ignore_index=True)
    saveExcel("C:\\Users\\prerna.prakash\\Desktop\\Input\\AgeDataNew.xlsx","Sheet1",dfsaveit)
    saveExcel("Z:\\Postpay\\WAR ROOM ORDERS\\Backlog_OSM_UIM\\AgeDataNew.xlsx","Sheet1",dfsaveit)

    
def sendAlert(msg):
    Sendmail.sendMail(msg)
    return msg