class UnlockSN(object):
    def __init__(self, sn):
        self.sn = sn.replace("\n", "") + "\n"
        self.localpath = os.path.split(os.path.realpath(__file__))[0]
        self.exepath = os.path.abspath(
            os.path.join(self.localpath,
                         "..\\win32tools\\openssl_102n\\openssl.exe"))
        self.pempath = os.path.abspath(
            os.path.join(self.localpath, ".\\pem\\challenge_private.pem"))
        self.sourcepath = ".\\sn.txt"
        self.resultpath = ".\\sign_result.txt"
        self.ls = LogShow("UnloclSN")

    def sign(self):
        try:
            w = open(self.sourcepath, 'wb')
            w.write(self.sn)
            w.close()
            os.system(self.exepath + " rsautl -sign -inkey " + self.pempath +
                      " -in " + self.sourcepath + " -out " + self.resultpath)
            f = open(self.resultpath, 'rb')
            unlockstrs = ""
            for line in f.readlines():
                unlockstrs = unlockstrs + line
            f.close()
            result = base64.b64encode(unlockstrs)
            return result
        except Exception, e:
            self.ls.log_pring(str(e))
class getVideoLog(object):
    def __init__(self, ip, user, password, logpath):
        self.url = ip
        self.logpath = logpath
        self.user = user
        self.password = password
        objectname = "Get Video Log"
        self.ls = LogShow(objectname)
        self.ls.log_print("system", "start get log now ..")

    def _async_raise(self, tid, exctype):
        try:
            """raises the exception, performs cleanup if needed"""
            tid = ctypes.c_long(tid)
            if not inspect.isclass(exctype):
                exctype = type(exctype)
            res = ctypes.pythonapi.PyThreadState_SetAsyncExc(
                tid, ctypes.py_object(exctype))
            if res == 0:
                raise ValueError("invalid thread id")
            elif res != 1:
                # """if it returns a number greater than one, you're in trouble,
                # and you should call it again with exc=NULL to revert the effect"""
                ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
                raise SystemError("PyThreadState_SetAsyncExc failed")
        except Exception, e:
            self.ls.log_print("debug", str(e))
    def __init__(self,ipadd,fm_path,session=None):
        self.class_name = 'Update'
        self.ls = LogShow(self.class_name)
        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        if not Check.checkIP(self.ip):
            self.ls.log_print('warn', self.ip + ' is not valuable!', '__init__')
        if isinstance(fm_path, str):            
            self.firmware_path = fm_path
        else:
            self.firmware_path = str(fm_path)

        self.url_update = 'http://' + self.ip + '/service/system/firmware_upgrade/full_update'
        self.url_status = 'http://' + self.ip + '/service/system/task/status'
        self.url_update_new = 'http://' + self.ip + '/service/system/system_upgrade'
        self.url_restore = 'http://' + self.ip + '/service/system/restore'
        self.url_stop = 'http://' + self.ip + '/service/system/stop'
        self.url_start = 'http://' + self.ip + '/service/system/start'
        
        self.login = LogIn(self.ip)
        if session is None:
            self.Login()
        else:
            self.session = session
 def __init__(self, ip):
     self.func_name = "GetSysInfo"
     self.ls = LogShow(self.func_name)
     self.ip = ip
     self.user = "******"
     self.password = "******"
     self.ssh = Ssh(self.ip, self.user, self.password)
Esempio n. 5
0
class getVideoLog(object):

    def __init__(self, ip, user, password, logpath):
        self.url = ip
        self.logpath = logpath
        self.user = user
        self.password = password
        objectname = "Get Video Log"
        self.ls = LogShow(objectname)
        self.ls.log_print("system", "start get log now ..")

    def _async_raise(self, tid, exctype):
        try:
            """raises the exception, performs cleanup if needed"""
            tid = ctypes.c_long(tid)
            if not inspect.isclass(exctype):
                exctype = type(exctype)
            res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
            if res == 0:
                raise ValueError("invalid thread id")
            elif res != 1:
                # """if it returns a number greater than one, you're in trouble,
                # and you should call it again with exc=NULL to revert the effect"""
                ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
                raise SystemError("PyThreadState_SetAsyncExc failed")
        except Exception,e:
            self.ls.log_print("debug", str(e))
    def __init__(self, testname, testresult, test_time_start, test_time_end, test_time_used, test_times_all, test_detail, build_status, error_reason):
        self.ls = LogShow("createJson")
        self.ls.log_print("system", "[createJson] -- start")
        try:
            if testname != None and testname != "" :
                self.testname = testname
            else :
                self.ls.log_print("error", "the testname is None or \'\' !")

            if testresult != None and testresult !="" :
                self.testresult = testresult
            else :
                self.testresult = "fail"

            if test_time_start != None and test_time_start != "" :
                self.test_time_start = test_time_start
            else :
                self.test_time_start = time.strftime('%Y-%m-%d-%H:%M:%S',time.localtime(time.time()))

            if test_time_end != None and test_time_end != "" :
                self.test_time_end = test_time_end
            else :
                self.test_time_end = time.strftime('%Y-%m-%d-%H:%M:%S',time.localtime(time.time()))

            if test_time_used != None and test_time_used != "" :
                self.test_time_used = test_time_used
            else :
                self.test_time_used = "0s"

            if test_times_all != None and test_times_all != "" and test_times_all != 0 :
                self.test_times_all = 1
            else :
                self.test_times_all = 1

            if build_status != None and build_status != "" :
                self.build_status = build_status
            else :
                self.build_status = "Abort"
            
            if error_reason != None and error_reason != "" :
                self.error_reason = error_reason
            else :
                self.error_reason = "don't know why, see log please!"
                
            self.test_detail = [
                {
                    "test_times" : 1,
                    "test_result" : "failed",
                    "test_time_start" : self.test_time_start,
                    "test_time_end" : self.test_time_end,
                    "test_time_used" : self.test_time_used,
                    "test_log_path" : ".\\log\\",
                    "test_movie_path" : ".\\log\\",
                    "test_report_path" : ".\\log\\"
                }
            ]

        except Exception,e:
            self.ls.log_print("error", "wrong with something " + str(e))
 def __init__(self,ip):
     toolname = "zeustools"
     self.ls = LogShow(toolname)
     self.localpath = os.path.split(os.path.realpath(__file__))[0]
     self.logexepath = os.path.abspath(os.path.join(self.localpath,"..\\win32tools"))
     self.tool = self.logexepath + "\\zeustoolnew.exe"
     self.ip = ip
     self.tool_t = self.tool + " -t " + self.ip + " "
 def __init__(self, ip, user, password, logpath):
     self.url = ip
     self.logpath = logpath
     self.user = user
     self.password = password
     objectname = "Get Video Log"
     self.ls = LogShow(objectname)
     self.ls.log_print("system", "start get log now ..")
 def __init__(self, ipadd):
     self.name = "GetVersion"
     self.ip = ipadd
     self.content = str()
     self.url_login = '******' + self.ip + '/service/system/login'
     self.url_version = "http://" + self.ip + "/service/system/firmware_upgrade/version"
     self.data_login = {'name': 'admin', 'pw': 'admin111'}
     self.ls = LogShow(self.name)
Esempio n. 10
0
 def __init__(self,ipadd):
     self.ip = ipadd
     self.url_login = '******' + self.ip + '/service/system/login'
     self.url_open = 'http://' + self.ip + '/service/system/diagnosis'
     self.url_status = 'http://' + self.ip + '/service/system/diagnosis/status'
     self.url_msg = 'http://' + self.ip + '/service/system/diagnosis/msg'
     self.data_login = {'name':'admin', 'pw':'admin111'}
     self.ls = LogShow("GetDiagnosis")
     self.msg = ""
     self.found_para = False
 def __init__(self, ipadd, fm_path):
     self.ip = ipadd
     self.url_login = '******' + self.ip + '/service/system/login'
     self.url_update = 'http://' + self.ip + '/service/system/firmware_upgrade/full_update'
     self.url_status = 'http://' + self.ip + '/service/system/task/status'
     self.url_update_new = 'http://' + self.ip + '/service/system/system_upgrade'
     self.url_restore = 'http://' + self.ip + '/service/system/restore'
     self.firmware_path = fm_path
     self.data_login = {'name': 'admin', 'pw': 'admin111'}
     self.ls = LogShow("Update")
Esempio n. 12
0
    def __init__(self, ipadd, session=None):
        self.class_name = 'GetVersion'
        self.ls = LogShow(self.class_name)

        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        if not Check.checkIP(self.ip):
            self.ls.log_print('warn', self.ip + ' is not valuable', '__init__')
        self.webcontroller = WebController(self.ip, session)
 def __init__(self, sn):
     self.sn = sn.replace("\n", "") + "\n"
     self.localpath = os.path.split(os.path.realpath(__file__))[0]
     self.exepath = os.path.abspath(
         os.path.join(self.localpath,
                      "..\\win32tools\\openssl_102n\\openssl.exe"))
     self.pempath = os.path.abspath(
         os.path.join(self.localpath, ".\\pem\\challenge_private.pem"))
     self.sourcepath = ".\\sn.txt"
     self.resultpath = ".\\sign_result.txt"
     self.ls = LogShow("UnloclSN")
Esempio n. 14
0
class Ssh(object):
    def __init__(self,ipadd,username,password):
        self.ip = ipadd
        self.username = username
        self.password = password
        self.ls = LogShow("SSH")

    def Connect(self):
        try:
            self.connect = paramiko.SSHClient()
            self.connect.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            self.connect.connect(self.ip,22,self.username,self.password,timeout=5)
        except Exception,e:
            self.ls.log_print("system","[SSH Connect] : wrong with it -- " + str(e))
class CheckIP(object):
    def __init__(self):
        self.func_name = "CheckIP"
        self.ls = LogShow(self.func_name)
        self.jsonpath = "../../../testcases/testcases.json"

    def getjson(self):
        try:
            f = open(self.jsonpath, "r")
            jsonstr = json.load(f)
            f.close()
            self.jsoninfo = self.byteify(jsonstr)
        except Exception, e:
            self.ls.log_print("error", str(e))
Esempio n. 16
0
class Sftp(object):
    def __init__(self,ipadd):
        self.ip = ipadd        
        self.ls = LogShow("SFTP")
        self.username = "******"
        self.password = "******"

    def Connect(self):
        try:
            self.ls.log_print("system", "[Sftp connect] " + str(self.ip))
            self.sftp = paramiko.Transport(self.ip,22)
            self.sftp.connect(username=self.username,password=self.password)
            self.sf = paramiko.SFTPClient.from_transport(self.sftp)
        except Exception,e:
            self.ls.log_print("system", "[Sftp connect] : wrong with it -- " + str(e))
Esempio n. 17
0
class Sftp(object):
    def __init__(self, ipadd):
        self.ip = ipadd
        self.ls = LogShow("SFTP")
        self.username = "******"
        self.password = "******"

    def Connect(self):
        try:
            self.ls.log_print("system", "[Sftp connect] " + str(self.ip))
            self.sftp = paramiko.Transport(self.ip, 22)
            self.sftp.connect(username=self.username, password=self.password)
            self.sf = paramiko.SFTPClient.from_transport(self.sftp)
        except Exception, e:
            self.ls.log_print("system",
                              "[Sftp connect] : wrong with it -- " + str(e))
Esempio n. 18
0
class Flash(object):
    def __init__(self):
        self.ls = LogShow("Root")
        self.ls.log_print("system", "[Flash]")

    def fileExist(self, filepath):
        return os.path.exists(filepath)

    def getEnv(self, envname):
        try:
            if envname != None and envname != "":
                return os.getenv(envname)
            else:
                return ""
        except Exception, e:
            self.ls.log_print("error", "[getenvv] failed with " + envname)
            return ""
Esempio n. 19
0
 def __init__(self, ip, user, password, logpath):
     self.url = ip
     self.logpath = logpath
     self.user = user
     self.password = password
     objectname = "Get Video Log"
     self.ls = LogShow(objectname)
     self.ls.log_print("system", "start get log now ..")
Esempio n. 20
0
class GetSN(object):

    def __init__(self, ipadd, session):
        self.class_name = 'GetSN'
        

        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        
        self.login = LogIn(self.ip)

        if session is not None:
            self.session = session
        else:
            self.session = self.reLogin()

        url_pre = 'http://' + self.ip
        self.url_sn = url_pre + '/service/system/admin/sn'
        self.url_version = url_pre + '/service/system/firmware_upgrade/version'
        
        self.ls = LogShow(self.class_name)
        self.getContent()


    def __str__(self):
        return self.class_name


    def reLogin(self):
        return  self.login.login()

    @checkSN
    def getContent(self):
        try:
            self.SNcontent = self.session.get(self.url_sn).text
            self.snJson = json.loads(self.SNcontent)
            time.sleep(5)
            self.VEcontent = self.session.get(self.url_version).text
            self.veJson = json.loads(self.VEcontent)
        except Exception,e:
            self.ls.log_print('error', str(traceback.print_exc()), self.getContent.__name__)
            time.sleep(5)
            self.getContent()
Esempio n. 21
0
    def __init__(self, ipadd, username, password):
        self.class_name = "Ssh"

        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        if isinstance(username, str):
            self.username = username
        else:
            self.username = str(username)
        if isinstance(password, str):
            self.password = password
        else:
            self.username = str(password)

        self.ls = LogShow(self.class_name)
        self.Connect()
 def __init__(self, ipadd):
     self.ip = ipadd
     self.url_login = '******' + self.ip + '/service/system/login'
     self.url_debug = 'http://' + self.ip + '/service/system/admin/challenge'
     self.url_unroot = 'http://' + self.ip + '/service/system/admin/unroot'
     self.url_sn = 'http://' + self.ip + '/service/system/admin/sn'
     self.url_version = "http://" + self.ip + "/service/system/firmware_upgrade/version"
     self.url_diagnosis = "http://" + self.ip + "/service/system/diagnosis"
     self.data_login = {'name': 'admin', 'pw': 'admin111'}
     self.ssh_user = "******"
     self.ssh_pass = "******"
     self.unlock_info = {
         'ip': '10.16.2.160',
         'user': '******',
         'pass': '******'
     }
     self.data_debug = None
     self.ls = LogShow("Root")
Esempio n. 23
0
 def __init__(self, ipadd, session=None):
     self.ip = ipadd
     self.class_name = "WebController"
     self.ls = LogShow(self.class_name)
     if not hasattr(self, "session"):
         if session is None:
             self.login()
         else:
             self.session = session
Esempio n. 24
0
class Ssh(object):
    def __init__(self, ipadd, username, password):
        self.ip = ipadd
        self.username = username
        self.password = password
        self.ls = LogShow("SSH")

    def Connect(self):
        try:
            self.connect = paramiko.SSHClient()
            self.connect.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            self.connect.connect(self.ip,
                                 22,
                                 self.username,
                                 self.password,
                                 timeout=5)
        except Exception, e:
            self.ls.log_print("system",
                              "[SSH Connect] : wrong with it -- " + str(e))
Esempio n. 25
0
    def __init__(self, ipadd, session):
        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        if isinstance(session, requests.Session):
            self.session = session
        else:
            self.session = self.reLogin()
        self.class_name = 'GetDiagnosis'
        url_pre = 'http://' + self.ip
        self.url_open = url_pre + '/service/system/diagnosis'
        self.url_status = url_pre + '/service/system/diagnosis/status'
        self.url_msg = url_pre + '/service/system/diagnosis/msg'
        self.url_close = self.url_open

        self.ls = LogShow(self.class_name)
        self.msg = ""
        self.found_para = False

        self.open_data = {'diagnosis':'enable'}
        self.close_data = {'diagnosis':'disable'}
Esempio n. 26
0
    def __init__(self, ipadd, session):
        self.class_name = 'GetSN'
        

        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        
        self.login = LogIn(self.ip)

        if session is not None:
            self.session = session
        else:
            self.session = self.reLogin()

        url_pre = 'http://' + self.ip
        self.url_sn = url_pre + '/service/system/admin/sn'
        self.url_version = url_pre + '/service/system/firmware_upgrade/version'
        
        self.ls = LogShow(self.class_name)
        self.getContent()
Esempio n. 27
0
class Ftp(object):
    
    def __init__(self, ip, port=21, bufsize=1024, username=None, password=None):
        self.class_name = "Ftp"
        self.ls = LogShow(self.class_name)
        if not Check.checkIP(ip):
            self.ls.log_print('warn', ip + ' is not valuable !')
        
        self.ip = ip
        
        if username is not None:
            self.username = username
        else:
            self.username = '******'
        
        if password is not None:
            self.password = password
        else:
            self.password = None

        self.port = (int)port
        self.bufsize = (int)bufsize

        if not hasattr(self,'ftp'):
            self.ftp = FTP()
        self.Connect()
        
        

    def __str__(self):
        return self.class_name

    def Connect(self):
        try:
            self.ftp.connect(self.ip, self.port)
            self.ftp.login(self.username, self.password)
        except Exception,e:
            self.ls.log_print('error', str(e))
Esempio n. 28
0
class Ssh(object):
    def __init__(self, ipadd, username, password):
        self.class_name = "Ssh"

        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        if isinstance(username, str):
            self.username = username
        else:
            self.username = str(username)
        if isinstance(password, str):
            self.password = password
        else:
            self.username = str(password)

        self.ls = LogShow(self.class_name)
        self.Connect()

    def __str__(self):
        return self.class_name

    def Connect(self):
        try:
            if not hasattr(self, "connect"):
                self.connect = paramiko.SSHClient()
                self.connect.set_missing_host_key_policy(
                    paramiko.AutoAddPolicy())
                self.connect.connect(self.ip,
                                     22,
                                     self.username,
                                     self.password,
                                     timeout=5)

        except Exception, e:
            self.ls.log_print("system", "wrong with it -- " + str(e),
                              self.Connect.__name__)
Esempio n. 29
0
    def __init__(self, ipadd, username="******", password="******"):

        self.class_name = "Sftp"
        self.ls = LogShow(self.class_name)

        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        if not Check.checkIP(self.ip):
            self.ls.log_print('warn', self.ip + 'is not the valuable ip!',
                              '__init__')

        if isinstance(username, str):
            self.username = username
        else:
            self.username = str(username)
        if isinstance(password, str):
            self.password = password
        else:
            self.username = str(password)

        self.Connect()
Esempio n. 30
0
    def __init__(self, ip, port=21, bufsize=1024, username=None, password=None):
        self.class_name = "Ftp"
        self.ls = LogShow(self.class_name)
        if not Check.checkIP(ip):
            self.ls.log_print('warn', ip + ' is not valuable !')
        
        self.ip = ip
        
        if username is not None:
            self.username = username
        else:
            self.username = '******'
        
        if password is not None:
            self.password = password
        else:
            self.password = None

        self.port = (int)port
        self.bufsize = (int)bufsize

        if not hasattr(self,'ftp'):
            self.ftp = FTP()
        self.Connect()
class Update(object):

    def __init__(self,ipadd,fm_path,session=None):
        self.class_name = 'Update'
        self.ls = LogShow(self.class_name)
        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        if not Check.checkIP(self.ip):
            self.ls.log_print('warn', self.ip + ' is not valuable!', '__init__')
        if isinstance(fm_path, str):            
            self.firmware_path = fm_path
        else:
            self.firmware_path = str(fm_path)

        self.url_update = 'http://' + self.ip + '/service/system/firmware_upgrade/full_update'
        self.url_status = 'http://' + self.ip + '/service/system/task/status'
        self.url_update_new = 'http://' + self.ip + '/service/system/system_upgrade'
        self.url_restore = 'http://' + self.ip + '/service/system/restore'
        self.url_stop = 'http://' + self.ip + '/service/system/stop'
        self.url_start = 'http://' + self.ip + '/service/system/start'
        
        self.login = LogIn(self.ip)
        if session is None:
            self.Login()
        else:
            self.session = session

    def Login(self):
        self.session = self.login.login()

    def __str__(self):
        return self.class_name

    def reLogin(self):
        self.Login()

    @checkSN
    def stopSlamware(self):
        try:
            self.ls.log_print('system', 'stop the slamwared now', self.stopSlamware.__name__)
            self.session.post(self.url_stop)
            self.ls.log_print('system', 'stop slamwared ok ', self.stopSlamware.__name__)
        except Exception,e:
            self.ls.log_print('error', str(e),  self.stopSlamware.__name__)
class getDate(object):

    timestr = '%Y-%m-%d-%H:%M:%S'
    class_name = 'getDate'
    ls = LogShow(class_name)
    #if using python 3.4
    #timestr = '%Y-%m-%d-%H:%M:%S.%f'
    def __init__(self):
        self.class_name = 'getDate'
        self.ls = LogShow(self.class_name)
        self.timestr = '%Y-%m-%d-%H:%M:%S'

    def __str__(self):
        return self.class_name

    @classmethod
    def getdatetoday(cls):
        return time.strftime(cls.timestr, time.localtime(time.time()))
    
    @classmethod
    def getsomedate(cls, dev=0):
        if dev is 0:
            return cls().getdatetoday()
        else:
            today_date = datetime.datetime.now()
            need_date = today_date + datetime.timedelta(days=dev)
            return need_date.strftime(cls.timestr)

    @classmethod
    def getdatefromstr(cls, string):
        if string is not None and isinstance(string, str):
            afterstr = re.compile("[0-9]{4}-(0[0-9]|1[0-2])-([0|1|2][0-9]|3[0-1])-([0|1][1-9]|2[0-3]).[0-5][0-9].[0-5][0-9]")
            if afterstr.match(string):   
                need_date = datetime.datetime.strptime(string, cls.timestr)
                return need_date
            else:
                cls().ls.log_print('warn', string + ' is invalued date-time string')
                return None
Esempio n. 33
0
class GetDiagnosis(object):

    def __init__(self, ipadd, session):
        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        if isinstance(session, requests.Session):
            self.session = session
        else:
            self.session = self.reLogin()
        self.class_name = 'GetDiagnosis'
        url_pre = 'http://' + self.ip
        self.url_open = url_pre + '/service/system/diagnosis'
        self.url_status = url_pre + '/service/system/diagnosis/status'
        self.url_msg = url_pre + '/service/system/diagnosis/msg'
        self.url_close = self.url_open

        self.ls = LogShow(self.class_name)
        self.msg = ""
        self.found_para = False

        self.open_data = {'diagnosis':'enable'}
        self.close_data = {'diagnosis':'disable'}

    def __str__(self):
        return self.class_name

    def reLogin(self):
        login = LogIn(self.ip)
        return login.login()

    @checkSN
    def OpenDiagnosis(self):
        try:
            self.ls.log_print("system", 'try to open diagnosis', self.OpenDiagnosis.__name__)
            self.session.post(url=self.url_open, data=self.open_data)
            self.ls.log_print("system", 'ok', self.OpenDiagnosis.__name__)
            return self.getStatusofOpen()
        except Exception,e:
            self.ls.log_print("system", str(traceback.print_exc()), self.OpenDiagnosis.__name__)
            return False
Esempio n. 34
0
class Sftp(object):
    def __init__(self, ipadd, username="******", password="******"):

        self.class_name = "Sftp"
        self.ls = LogShow(self.class_name)

        if isinstance(ipadd, str):
            self.ip = ipadd
        else:
            self.ip = str(ipadd)
        if not Check.checkIP(self.ip):
            self.ls.log_print('warn', self.ip + 'is not the valuable ip!',
                              '__init__')

        if isinstance(username, str):
            self.username = username
        else:
            self.username = str(username)
        if isinstance(password, str):
            self.password = password
        else:
            self.username = str(password)

        self.Connect()

    def __str__(self):
        return self.class_name

    def Connect(self):
        try:
            if not hasattr(self, "sftp"):
                self.ls.log_print("system", "connect to  " + str(self.ip),
                                  self.Connect.__name__)
                self.sftp = paramiko.Transport(self.ip, 22)
                self.sftp.connect(username=self.username,
                                  password=self.password)
                self.sf = paramiko.SFTPClient.from_transport(self.sftp)
        except Exception, e:
            self.ls.log_print("system", "wrong with it -- " + str(e),
                              self.Connect.__name__)
Esempio n. 35
0
 def __init__(self,ipadd):
     self.ip = ipadd        
     self.ls = LogShow("SFTP")
     self.username = "******"
     self.password = "******"
Esempio n. 36
0
 def __init__(self,ipadd,username,password):
     self.ip = ipadd
     self.username = username
     self.password = password
     self.ls = LogShow("SSH")
Esempio n. 37
0
class Getfiles(object):
    def __init__(self):
        self.ls = LogShow("GetFile")
        self.ls.log_print ("system", "[getfiles]------------")
       
    def Getfile(self,remote,local):
        self.ls.log_print ("system", "[getfile] remote: " + str(remote))
        self.ls.log_print ("system", "[getfile] local : " + str(local))
        copycmd = "xcopy /yse %s  %s\\ "%(remote,local)
        self.ls.log_print ("system", "[getfile] cmd= " + str(copycmd))
        if os.system(copycmd) == 0 :
            self.ls.log_print ("system", "[getfile] copy ok")
        else:
            self.ls.log_print ("system", "[getfile] copy fail")
            exit(1)
       
    def Getfile_filename(self,remote,local,filename):
        self.ls.log_print ("system", "[getfile] remote: " + str(remote + "\\" + filename))
        self.ls.log_print ("system", "[getfile] local : " + str(local + "\\" + filename))
        copycmd = "echo F | xcopy /yse %s  %s "%(remote +"\\" + filename,local +"\\" + filename)
        self.ls.log_print ("system", "[getfile] cmd= " + str(copycmd))
        if os.system(copycmd) == 0 :
            self.ls.log_print ("system", "[getfile] copy ok")
        else:
            self.ls.log_print ("system", "[getfile] copy fail")
            exit(1)

    def Getfile_1(self,remote,local):
        self.ls.log_print ("system", "[getfile] remote: " + str(remote))
        self.ls.log_print ("system", "[getfile] local : " + str(local))
        copycmd = "echo F | xcopy /yse %s  %s "%(remote,local)
        self.ls.log_print ("system", "[getfile] cmd= " + str(copycmd))
        if os.system(copycmd) == 0 :
            self.ls.log_print ("system", "[getfile] copy ok")
        else:
            self.ls.log_print ("system", "[getfile] copy fail")
            exit(1)
    

    
    def Getftpfile(self,remote,local):
        self.ls.log_print ("system", "[getftpfile] remote : " + str(remote))
        self.ls.log_print ("system", "[getftpfile] local  : " + str(local))

    def GetSCPfile(self,remote,local,ip):
        self.ls.log_print ("system", "[getscpfile] remote : " + str(remote))
        self.ls.log_print ("system", "[getscpfile] local  : " + str(local))
        sftp = Sftp(ip)
        sftp.Connect()
        sftp.GetFile(reomte,local)
Esempio n. 38
0
 def __init__(self):
     self.ls = LogShow("GetFile")
     self.ls.log_print ("system", "[getfiles]------------")