def main(ison): #copyto("c:",ison) #copyto("f:",ison) copyto(bakdrive, ison) if destdrive != "C:": #only c if os.path.splitdrive(getpath.getpath())[0] == "H:": copyto("g:", ison) else: copyto("h:", ison) else: if os.path.splitdrive(getpath.getpath())[0] == "E:": copyto("F:", ison) else: copyto("E:", ison)
def main(): curpath=getpath.getpath() hm=getbh() hm=hm[-8:] if not ison(): fs=mylistdir("../CS","*.ini") fn="..\\CS" #cmd='xcopy /s /Y %s "c:\\Program Files\\NCS\\CS3000\\CS\\"' % fn cmd='xcopy /s /Y %s "%s\\Program Files (X86)\\NCS\\CS3000\\CS\\"' % (fn,destdrive) print(cmd) os.system(cmd) cmd=curpath+"\\LicenseManager.exe %s 80" % hm print(cmd) os.system(cmd) #cmd='xcopy /Y sfx.db3 "c:\\Program Files\\NCS\\CS3000\\"' cmd='xcopy /Y sfx.db3 "'+destdrive+'\\Program Files (X86)\\NCS\\CS3000\\"' print(cmd) os.system(cmd) else: fn="..\\ON" fs=mylistdir("../ON","*.ini") #cmd='xcopy /s /Y %s "c:\\Program Files\\NCS\\ONH3000\\ON\\"' % fn cmd='xcopy /s /Y %s %s\\Program Files (X86)\\NCS\\ONH3000\\ON\\"' % (fn,destdrive) os.system(cmd) fn="Configs.db" #cmd='xcopy /Y %s "c:\\Program Files\\NCS\\ONH3000\\"' % fn cmd='xcopy /Y %s %s\\Program Files (X86)\\NCS\\ONH3000\\"' % (fn,destdrive) os.system(cmd) cmd=curpath+"\\LicenseManager.exe %s 80" % hm os.system(cmd) #cmd='xcopy /Y sfx.db3 "c:\\Program Files\\NCS\\ONH3000\\"' cmd='xcopy /Y sfx.db3 "'+destdrive+'\\Program Files (X86)\\NCS\\ONH3000\\"' os.system(cmd)
def copyto(dest, ison): # if ison: # todir='%s\\ONH3000V2.1.31\\' % dest # if os.path.exists(todir): # return # else: # todir='%s\\CS3000v1.6.19\\' % dest # if os.path.exists(todir): # return curpath = getpath.getpath() if ison: #copy 9111 cmd = "xcopy /s %s\\..\\..\\刻盘\\9111 %s\\9111\\" % (curpath, dest) print(cmd) if os.path.exists(dest + "\\9111"): pass else: os.system(cmd) # cmd = 'xcopy /s "%s\\..\\..\\刻盘\\ONH3000v2.1.33" %s\\ONH3000v2.1.33\\' % ( curpath, dest) print(cmd) if os.path.exists(dest + "\\ONH3000v2.1.33"): pass else: os.system(cmd) else: cmd = 'xcopy /s "%s\\..\\..\\刻盘\\CS3000备份" %s\\CS3000备份\\' % (curpath, dest) print(cmd) if os.path.exists(dest + "\\CS3000备份"): pass else: os.system(cmd)
def __pathfinder(self, info): path = raw_input(info).strip() if path=="": path = getpath() if not isdir(path): raise self.reduceError("\"{}\" is not a valid file path".format(path)) else: return path
def regcs(): curpath = getpath.getpath() hm = getbh() hm = hm[-8:] fs = mylistdir("../CS", "*.ini") fn = "..\\CS" #cmd='xcopy /s /Y %s "c:\\Program Files\\NCS\\CS3000\\CS\\"' % fn cmd = 'xcopy /s /Y %s "C:\\Users\\ncs\\Desktop\\CS3000_1.6.18\\"' % (fn) print(cmd) os.system(cmd) cmd = curpath + "\\LicenseManager.exe %s 80" % hm print(cmd) os.system(cmd) #cmd='xcopy /Y sfx.db3 "c:\\Program Files\\NCS\\CS3000\\"' cmd = 'xcopy /Y sfx.db3 "C:\\Users\\ncs\\Desktop\\CS3000_1.6.18\\"' print(cmd) os.system(cmd)
class Excel_Zhuce(object): wb = load_workbook(getpath('canshu.xlsx')) sheet = wb.get_sheet_by_name('注册') user, passwd, re_passwd, email, perfact = [0], [0], [0], [0], [ sheet.cell(row=2, column=6).value ] for i in range(3, 8): user.append(sheet.cell(row=i, column=2).value) passwd.append(sheet.cell(row=i, column=3).value) re_passwd.append(sheet.cell(row=i, column=4).value) email.append(sheet.cell(row=i, column=5).value) perfact.append(sheet.cell(row=i, column=6).value) sheet1 = wb.get_sheet_by_name('主页面') url = sheet1.cell(row=2, column=1).value # print(perfact) # Excel_Zhuce()
# -*- coding: utf-8 -*- import clr import sys # import math import getpath drv=getpath.getpath().split("\\")[0] clr.AddReferenceByPartialName("IronPython") initpath=drv+r"\soft\rtf1\RtfConverter_v1.7.0\bin\Release" sys.path.append(initpath) clr.AddReference("Itenso.Rtf.Parser.dll") # import Itenso.Rtf from Itenso.Rtf.Parser import RtfParserListenerStructureBuilder,RtfParser from Itenso.Rtf.Support import RtfSource from Itenso.Rtf.Model import RtfElementCollection,RtfTag,RtfGroup,RtfText # import System # from System.IO import * import codecs wz={"仪器型号":13,"仪器编号":17 ,"调试人员":20 ,"频率第一天":23 ,"频率第二天":25 ,"频率第三天":27 ,"压差第一天":41 ,"压差第二天":43 ,"压差第三天":45 ,"红外":56 ,"马达":58 ,"温度":60 ,"LC_L":72 ,"LC_K":73 ,"LC_B":74
#!/usr/bin/python3 from PIL import Image from getpath import getpath import os path = getpath('../../set/pic') size = (1920, 1080) fl = os.listdir(path) for name in fl: im = Image.open(os.path.join(path, name)) bx = size[0] // 2 - im.size[0] // 2 by = size[1] // 2 - im.size[1] // 2 ex = size[0] // 2 + im.size[0] // 2 ey = size[1] // 2 + im.size[1] // 2 p = Image.new('RGBA', size, (255, 255, 255)) p.paste(im, (bx, by)) p.save(os.path.join(path, name), format="png") print(name + ": Done.")
import ctypes, sys from getpath import getpath from main2 import main initpath = getpath() sys.path.insert(0, initpath + "\Lib") print(sys.path) def is_admin(): try: return ctypes.windll.shell32.IsUserAnAdmin() except: return False if is_admin(): # 将要运行的代码加到这里 main() else: if sys.version_info[0] == 3: ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1) main()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import json import sys import os from getpath import getpath path = getpath('../../set') js = json.load(open(os.path.join(path, "info.json"), "r")) teams = open(os.path.join(path, "teams.tab"), "w") accounts = open(os.path.join(path, "accounts.tab"), "w") info = json.load(open(os.path.join(path, "SchoolInfo.json"))) def eraseZ(xx): i = 0 while True: if xx[i] != '0': break i = i + 1 return xx[i:] def addto3(xx): return format(xx, '0>3') ID = {
# -*- coding: utf-8 -*- import logging import datetime import time import jinja2 from obj_sqlalchemy import * logging.basicConfig() log = logging.getLogger() log.setLevel(logging.DEBUG) import codecs import xlrd import os from sqlalchemy import create_engine,desc,or_,and_ from sqlalchemy.orm import sessionmaker import getpath print(getpath.getpath()) yqzl=getpath.getpath()+r"media\仪器资料" filedb=getpath.getpath()+r"data.sqlite" engine = create_engine('sqlite:///'+filedb, echo=True) Session = sessionmaker(bind=engine) session = Session() print(yqzl) token=None islogin=False def readStandardFile(fn): filename=os.path.basename(fn) book = xlrd.open_workbook(fn) table=book.sheets()[0] nrows = table.nrows ncols = table.ncols begin=False
import json import os from getpath import getpath path = getpath('../../set/') with open(os.path.join(path, 'info.json')) as f: teams = json.load(f) tmp = "update team set room = '{}' where teamid = {};" with open(os.path.join(path, 'loc.sql'), 'w+') as f: for team in teams: print(tmp.format(team['location'], team['id']), file=f)
# -*- coding: utf-8 -*- import logging import datetime import time import jinja2 from obj_sqlalchemy import * logging.basicConfig() log = logging.getLogger() log.setLevel(logging.DEBUG) import codecs # import xlrd import os from sqlalchemy import create_engine, desc, or_, and_ from sqlalchemy.orm import sessionmaker import getpath print(getpath.getpath()) yqzl = getpath.getpath() + r"media\仪器资料" filedb = getpath.getpath() + r"/../data.sqlite" engine = create_engine('sqlite:///' + filedb, echo=True) Session = sessionmaker(bind=engine) token = None islogin = False def readStandardFile(fn): filename = os.path.basename(fn) book = xlrd.open_workbook(fn) table = book.sheets()[0] nrows = table.nrows ncols = table.ncols begin = False
#!/usr/bin/env python3 import json import os import threading from queue import Queue from getpath import getpath def addto3(xx): return format(xx, '0>3') tq = Queue(32) path = getpath('..') userName = open(os.path.join(path, 'set/userName')).read().strip('\n') js = json.load(open(os.path.join(path, 'set/info.json'))) homedir = '/home/' + userName + '/' wacc = 'echo "account: t{id}" > {fn}' wpwd = 'echo "password: {pwd}" >> {fn}' pscp = 'scp -o ConnectTimeout=1 {fn} {sscmd}:' + homedir + 'Desktop/account2longin.txt' def main(ssname, xx): tq.put(ssname) filename = os.path.join(path, '.cache/account2longin') + xx['location'] + '.txt' os.system(wacc.format(id=addto3(xx['externalid']), fn=filename))
def closeEvent(self,e): d=self.tableTodict() pickle.dump(d,open(getpath.getpath()+"data.pickle","w"))
import sys import os from PyQt4.QtCore import QFile,QIODevice,SIGNAL,QStringList from PyQt4.QtGui import QPushButton,QApplication,QLineEdit,QListWidget,QTextEdit,QTableWidget,QTableWidgetItem,QMenu,QAction,QFileDialog from PyQt4 import uic from getpath import getpath initpath = getpath() sys.stdout=open(initpath+"pymain.log","a") sys.stderr=sys.stdout import model import report import reportPdf from PyQt4.QtWebKit import * from OpenSample import OpenSample class MyApp(QApplication): def __init__(self): QApplication.__init__(self,[]) self.mainw=uic.loadUi(initpath+"main.ui")#l.loadUi(f,None) self.pushbutton_go=self.mainw.findChild(QPushButton,"pushButton_go") QApplication.connect(self.pushbutton_go,SIGNAL('clicked()'),self.handlego) self.pushButton_pdf=self.mainw.findChild(QPushButton,"pushButton_pdf") QApplication.connect(self.pushButton_pdf,SIGNAL('clicked()'),self.handlepdf) self.pushButton_rtf=self.mainw.findChild(QPushButton,"pushButton_rtf") QApplication.connect(self.pushButton_rtf,SIGNAL('clicked()'),self.handlertf) self.pushButton_excel=self.mainw.findChild(QPushButton,"pushButton_excel") QApplication.connect(self.pushButton_excel,SIGNAL('clicked()'),self.handleexcel) self.grid1=self.mainw.findChild(QTableWidget,"tableWidget")
import sys import os from PyQt4.QtCore import QFile,QIODevice,SIGNAL,QStringList from PyQt4.QtGui import QPushButton,QApplication,QLineEdit,QListWidget,QTextEdit,QTableWidget,QTableWidgetItem,QMenu,QAction,QFileDialog from PyQt4 import uic from getpath import getpath inipath = getpath() import model import report import reportPdf from PyQt4.QtWebKit import * from OpenSample import OpenSample class MyApp(QApplication): def __init__(self): QApplication.__init__(self,[]) self.mainw=uic.loadUi("main.ui")#l.loadUi(f,None) self.pushbutton_go=self.mainw.findChild(QPushButton,"pushButton_go") QApplication.connect(self.pushbutton_go,SIGNAL('clicked()'),self.handlego) self.pushButton_pdf=self.mainw.findChild(QPushButton,"pushButton_pdf") QApplication.connect(self.pushButton_pdf,SIGNAL('clicked()'),self.handlepdf) self.grid1=self.mainw.findChild(QTableWidget,"tableWidget") self.web1=self.mainw.findChild(QWebView,"webView") self.loadData() self.actionOpen_sample=self.mainw.findChild(QAction,"actionOpen_sample") self.connect(self.actionOpen_sample,SIGNAL('triggered (bool)'),self.OnOpenSample) self.actionClear_all=self.mainw.findChild(QAction,"actionClear_all") self.connect(self.actionClear_all,SIGNAL('triggered (bool)'),self.ClearAll)