Exemplo n.º 1
0
def main():
    # 打印Logo
    logo()
    ifContinue = True
    while ifContinue:
        model = Model()
        if model == '1':  #常规模式
            username = raw_input("Please input your username<<")
            password = raw_input("password<<")
            while (True):
                printf("Setting Browser...Please Wait", "purple")
                try:
                    browser = Login(username, password)
                except:
                    BaseException
                    print("Wrong password!")
                    username = raw_input("Please reinput your username<<")
                    password = raw_input("password<<")
                    continue

                printf("enter 0 to exit", "red")
                paperid = raw_input("Please input the ID of your paper<<")
                if paperid == '0':
                    break
                # 创建解答模块的实例
                #多线程2019.7.5
                try:
                    thread.start_new_thread(ModelOne, (browser, paperid))
                    printf("The Thread is Working ...")
                    time.sleep(1)
                except:
                    printf("Thread Error:unable to start thread", "red")

        if model == '2':
            printf("Warning ,this models is still in test!")
            username = raw_input("Please input your username<<")
            password = raw_input("password<<")
            browser = Login(username, password)
            while (True):
                papers = raw_input("How many papers do you want to Kill<<")
                for i in range(1, papers):
                    A = Answer()
                    A.GetAnswer(browser, i)
        if model == '3':
            printf("\n\tSettings is not available now!\n\n", 'blue')
        if model == '4':
            PrintInformation()
        if model == '5':
            ifContinue = False
            printf("Good Night!", "purple")
Exemplo n.º 2
0
 def _run(self):
     Logger.info("启动主服务器成功")
     Logger.info("开始进行OPENLAW模拟登陆")
     cookies = Login()._run()
     Logger.info("模拟登陆完成,已经获取用户cookies")
     Logger.info("进入爬虫系统")
     Clawer(self, cookies)._run_master()
    def getRequest(self, request_id):
        sd_ip = "10.71.67.39"
        try:

            print(sd_ip)
            token = Login.login(sd_ip)
            logging.debug(token)
            if token != None:
                header = {"Authorization": "Berear " + token}
                url = "https://" + sd_ip + "/LiveTime/services/v1/customer/requests/{}".format(
                    request_id)

                rest_data, rest_status = RestFactory().make_get_request(
                    url, header)
                logging.debug(rest_status)
                if rest_status == 200:
                    jsonResponse = json.loads(rest_data.decode('utf-8'))
                else:
                    jsonResponse = "No Request"
                logging.debug(jsonResponse)
            else:
                jsonResponse = None
            return jsonResponse
        except Exception as ex:
            print(traceback.format_exc())
            return None
Exemplo n.º 4
0
def GetUser():  # call back
    # 调用登陆模块
    username = entry1.get()
    password = entry2.get()
    print "Hello " + username + "!"
    printf("Setting Browser...Please Wait", "purple")

    try:
        browser = Login(username, password)
    except:
        BaseException
        print("Wrong password!")
Exemplo n.º 5
0
def ModelOne(argc,argv):
    # 调用登陆模块
    username = entry1.get()
    password = entry2.get()
    print "Hello " + username + "!"
    printf("Setting Browser...Please Wait", "purple")

    try:
        browser = Login(username, password)
    except:
        BaseException
        print("Wrong password!")

    x = entry_paper.get()
    paperid = int(x)

    A = Answer()
    A.GetAnswer(browser, paperid)
Exemplo n.º 6
0
 def create_request(self, description):
     try:
         sd_ip = "10.71.64.192"
         req_id = None
         token = Login.login(sd_ip)
         logging.debug(token)
         if token != None:
             header = {
                 "Authorization": "Berear " + token,
                 "Content-Type": "application/json"
             }
             post_body_data = '{"requestDescription":' + '"' + description + '"' + ', "subject":"Item category: Service and Item Type: Service Desk"}'
             url = "https://" + sd_ip + "/LiveTime/services/v1/customer/requests"
             rest_data, rest_status = RestFactory().make_post_request(
                 url, post_body_data, header)
             logging.debug(rest_status)
             if rest_status == 200:
                 req_id = json.loads(rest_data.decode('utf-8'))
         logging.debug(req_id)
         return req_id
     except Exception as ex:
         print(traceback.format_exc())
         return None
Exemplo n.º 7
0
 def _login(self):
     return Login().run()