手动导入一天的数据
# -*- coding:utf-8 -*-
#__author__ = 'ecaoyng'
# date : 20170627
from optparse import OptionParser
import commands
class pmImport:
def __init__(self, nwid, dateTime, prio, dir):
self.nwid=nwid
self.dateTime = dateTime
self.prio = prio
self.dir = dir
def pmDataImport(self):
# itkimport -type pm -nwid tlise -delete -job tlise_pm -jobopts dnfrf=1 -priority 3 /home/itk/spool/bk_20170623/20170621-1[5-6]*.zip
for i in range(24):
i = "%02d" % i
jobName=self.nwid+'_'+self.dateTime+'_'+str(i)
cmd = 'itkimport -type pm -delete -nwid ' + self.nwid + ' -jobopts dnfrf=1 -priority ' + self.prio + ' ' + self.dir + '/' + self.dateTime + '-' + str(i) + '*.zip' + ' -job ' + jobName
print(cmd)
try:
(status, output) = commands.getstatusoutput(cmd)
if status == 0:
print('=' * 60)
except Exception as err:
print(err)
if __name__== '__main__':
MSG_USAGE = "pmImport[ -d <dateTime>][-p <priority>] "
optParser = OptionParser(MSG_USAGE)
optParser.add_option("-n", action = "store",type="string",dest = "nwid",
help='nwid name')
optParser.add_option("-t",action = "store",type="string",dest = "dateTime",
help='Data time of pm data')
optParser.add_option("-p", action="store", type='string',dest="prio",default='3',
help="Set queue priority during data import")
optParser.add_option("-d", action = "store",type="string",dest = "dir",
help='Dir path of data')
options, args = optParser.parse_args()
# fakeArgs = ['-n','tlise','-t','20170627','-p', '2', '-d', '/var/opt']
# options, args = optParser.parse_args(fakeArgs)
# print(options.dateTime)
# print(options.prio)
# print(options.nwid)
# print(options.dir)
if options.dateTime == None:
print ('Please input dateTime with right format and refer to pmImport -h')
exit()
pmObj=pmImport(options.nwid, options.dateTime, options.prio, options.dir)
pmObj.pmDataImport()