资源简介
中兴配置软件STB_ConfigTool_V7.3.6_Bin_Site
代码片段和文件信息
import re
import sys
from ftplib import FTP
def usage():
s=“Usage:“
s+=“%s flag isControlFT isRename STBIP curStep passWord Path\n“%sys.argv[0]
s+=“\t flag: 0:stb->pc 1:pc->stb\n“
s+=“\t isControlFT: true OR false\n“
s+=“\t isRename: 0:pc->stb ProcessLog.txt 1:stb->pc ProcessLog2.txt\n“
s+=“\t stbip: stb‘s ipaddress\n“
s+=“\t curStep: curStep\n“
s+=“\t passWord: passWord\n“
s+=“\t Path: ProcessLog.txt‘s local path\n“
print s.decode(‘utf-8‘).encode(‘gbk‘)
def isIP(ip):
m=re.match(‘^(\d+)\.(\d+).(\d+).(\d+)$‘ip.strip())
if m:
isOK=True
for i in range(15):
ip=int(m.group(i))
if ip>255:
isOK=False
break
return isOK
else:
return False
if len(sys.argv)<8:
usage()
sys.exit(-1)
try:
flag=int(sys.argv[1])
except:
print “flag expect a 0 or 1you input %s“%sys.argv[1]
print “Unexpected error:“ sys.exc_info()[0]
sys.exit(-1)
if flag<0 or flag>1:
print “flag expect a 0 or 1you input %s“%sys.argv[1]
sys.exit(-1)
isControlFT=sys.argv[2].lower()
if isControlFT not in [‘true‘‘false‘]:
print “isControlFT should be in true or falseyou input %s“%sys.argv[2]
sys.exit(-1)
try:
isRename=int(sys.argv[3])
except:
print “isRename expect a 0 or 1you input %s“%sys.argv[3]
print “Unexpected error:“ sys.exc_info()[0]
sys.exit(-1)
if isRename<0 or isRename>1:
print “isRename expect a 0 or 1you input %s“%sys.argv[3]
sys.exit(-1)
stbip=sys.argv[4]
if not isIP(stbip):
print “stbip should be a valid ipyou input %s“%sys.argv[4]
sys.exit(-1)
try:
curStep=int(sys.argv[5])
except:
print “curStep should be a intyou input %s“%curStep
passWord=sys.argv[6]
Path=sys.argv[7]
def handleDownload(block):
file.write(block)
print “.“
ftp = FTP(stbip‘root‘ passWord)
print ‘Welcome to Matt\‘s ftplib example‘
print ‘Logging in.‘
directory = ‘/mnt/data‘
print ‘Changing to ‘ + directory
ftp.cwd(directory)
if flag==1:
if isRename==0:
#pc‘s ProcessLog.txt-->/mnt/data
filename = Path + ‘\ProcessLog.txt‘
filename1 = ‘ProcessLog.txt‘
print ‘Opening local file ‘ + filename
try:
file=open(filename“rb“)
except Exceptione:
print e
print ‘Putting ‘ + filename
ftp.storbinary(‘stor ‘ + filename1file)
else:
#/mnt/data‘s ProcessLog2.txt-->PC
filename = ‘ProcessLog2.txt‘
filename1 = Path + ‘\ProcessLog2.txt‘
print ‘Opening local file ‘ + filename
try:
#file=open(filename“wb“)
file=open(filename1“wb“)
except Exceptione:
print e
print ‘Getting ‘ + filename
ftp.retrb
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 86016 2012-04-09 17:31 STB_ConfigTool_V7.3.6_Bin_Site\3DES.dll
文件 2972 2012-10-09 11:41 STB_ConfigTool_V7.3.6_Bin_Site\B700V2A_128M.ini
文件 2236 2012-09-13 16:40 STB_ConfigTool_V7.3.6_Bin_Site\B700V3SH.ini
文件 28672 2012-07-06 15:16 STB_ConfigTool_V7.3.6_Bin_Site\DesSecretKey.dll
文件 2040 2012-07-06 15:16 STB_ConfigTool_V7.3.6_Bin_Site\DesSecretKey.lib
文件 4642 2012-07-13 15:48 STB_ConfigTool_V7.3.6_Bin_Site\ftpTrans.py
文件 1872 2012-10-30 20:43 STB_ConfigTool_V7.3.6_Bin_Site\log.txt
文件 0 2012-09-26 09:02 STB_ConfigTool_V7.3.6_Bin_Site\ProcessLog.txt
文件 661 2012-09-26 09:02 STB_ConfigTool_V7.3.6_Bin_Site\RebootCheckFilelog.txt
文件 0 2012-04-09 17:31 STB_ConfigTool_V7.3.6_Bin_Site\RecordSNLog.txt
文件 21 2012-09-26 09:03 STB_ConfigTool_V7.3.6_Bin_Site\selfinfo.ini
文件 3580 2012-08-06 15:21 STB_ConfigTool_V7.3.6_Bin_Site\StbBoardTestLog.txt
文件 1163264 2013-06-17 11:01 STB_ConfigTool_V7.3.6_Bin_Site\StbCfgToolc2.exe
文件 6431 2012-09-06 11:54 STB_ConfigTool_V7.3.6_Bin_Site\TelnetSTBFtp.py
文件 6178 2012-09-13 08:35 STB_ConfigTool_V7.3.6_Bin_Site\TelnetSTBFtpUpgradeAllmtd.py
文件 7948 2012-09-21 17:26 STB_ConfigTool_V7.3.6_Bin_Site\TelnetSTBRebootCheck.py
文件 24576 2012-04-09 17:31 STB_ConfigTool_V7.3.6_Bin_Site\VATTCP.dll
文件 4316 2012-04-09 17:31 STB_ConfigTool_V7.3.6_Bin_Site\xTelnetNew.py
文件 120 2012-05-14 10:00 STB_ConfigTool_V7.3.6_Bin_Site\工序配置例子.ini
目录 0 2013-07-14 13:22 STB_ConfigTool_V7.3.6_Bin_Site
----------- --------- ---------- ----- ----
1345545 20
- 上一篇:DEAP2.1软件及资料
- 下一篇:MCP3202 AD 驱动子程序
评论
共有 条评论