Beispiel #1
0
    def createUrl(self, params):
        url_base =  Lineage2DefaultUrlCreator.createUrl(self, params)
        if "CharName" in params:
            url_base += "&CharName=" + (str)(params["CharName"])

        if 'CharId' in params:
            return url_base + "&CharId=" + (str)(params['CharId'])
        else:
            raise InternalException(message="CharId is required!")
Beispiel #2
0
 def adapt(self, params=None):
     result = DefaultAdaptor.adapt(self, params)
     if 'job' in params:
         result.update({
             "SubJobDropDownList": params["job"],
             "change": "Change of a sub-class"
         })
         return result
     raise InternalException(message="Job field is required!")
Beispiel #3
0
    def getForPage(self, page):
        Factory.getForPage(self, page)
        pageName = page.pageName
        if pageName in self.names.keys():
            class_name = self.names[pageName]

            if not self.whereToSeek:
                raise InternalException(message='WhereToSeek is not defined!')

            for module in self.whereToSeek:
                try:
                    object = getattr(module, class_name)(page)
                except:
                    continue
                else:
                    return object
            raise InternalException(message=class_name + ' is not found in ' +
                                    self.whereToSeek)
        return None
Beispiel #4
0
 def createUrl(self, params):
     """
     params - dict
     """
     url = UrlCreator.createUrl(self, params)
     if params and ('url' in params):
         url += params['url']
     else:
         raise InternalException("Url is not defined!")
     return url
Beispiel #5
0
 def adapt(self, params=None):
     result = DefaultAdaptor.adapt(self, params)
     if "approve" in params:
         result.update({"approve": "Approve"})
         return result
     elif "reject" in params:
         result.update({"reject": "Reject"})
         return result
     else:
         raise InternalException(message="Approve or reject?")
Beispiel #6
0
 def getOpener(self):
     if not self.opener:
         url = self.getBaseUrl()
         if not url:
             raise InternalException('Base url is not defined!')
         cleared = re.sub(r"\W", r"_", url)
         jar = cookielib.FileCookieJar("cookies" + cleared +
                                       self.login_name)
         self.opener = urllib2.build_opener(
             urllib2.HTTPCookieProcessor(jar))
     return self.opener
Beispiel #7
0
        def inner(*args, **kwargs):
            try:
                #                пробуем выполнить действие
                return fun(*args, **kwargs)
            #            если не залогинены в админку, то
            except NotLoggedInException:
                # если у объекта-хозяина (L2AdminFacade) есть свойство support, будем использовать его.
                if hasattr(args[0], 'support') and args[0].support is not None:
                    support = args[0].support
                else:
                    raise InternalException(message="Support is not defined!")

                    #            логинимся
                login_page = Page(support, PageType.LOGIN_PAGE)
                try:
                    login_page.get()
                except LoginException as er:
                    #                    print("Could not log in L2Admin. Check your params")
                    raise er
                else:
                    # пробуем еще раз получить страницу
                    return fun(*args, **kwargs)
Beispiel #8
0
    def parse(self, page_str):
        page_str = Lineage2DefaultParser.parse(self, page_str)
        try:
            gender = (str)(self.lxlmldoc.xpath(
                '//*[@id="ModifyChar"]/table[4]/tr[4]/td[2]/text()')[0])
            for temp in self.lxlmldoc.xpath('//*[@id="gender"]/option'):
                if temp.text == gender:
                    gender = temp.xpath('@value')[0]
                    break

            race = self.lxlmldoc.xpath(
                '//*[@id="ModifyChar"]/table[4]/tr[4]/td[4]/text()')[0]
            for temp in self.lxlmldoc.xpath('//*[@id="race"]/option'):
                if temp.text == race:
                    race = temp.xpath('@value')[0]
                    break

            clazz = self.lxlmldoc.xpath(
                '//*[@id="ModifyChar"]/table[4]/tr[4]/td[6]/text()')[0]
            for temp in self.lxlmldoc.xpath('//*[@id="cls"]/option'):
                if temp.text == clazz:
                    clazz = temp.xpath('@value')[0]
                    break

            face = self.lxlmldoc.xpath(
                '//*[@id="ModifyChar"]/table[4]/tr[6]/td[2]/text()')[0]
            for temp in self.lxlmldoc.xpath('//*[@id="face"]/option'):
                if temp.text == face:
                    face = temp.xpath('@value')[0]
                    break

            hair_style = self.lxlmldoc.xpath(
                '//*[@id="ModifyChar"]/table[4]/tr[6]/td[4]/text()')[0]
            for temp in self.lxlmldoc.xpath('//*[@id="hairShape"]/option'):
                if temp.text == hair_style:
                    hair_style = temp.xpath('@value')[0]
                    break

            hair_color = self.lxlmldoc.xpath(
                '//*[@id="ModifyChar"]/table[4]/tr[6]/td[6]/text()')[0]
            for temp in self.lxlmldoc.xpath('//*[@id="hairColor"]/option'):
                if temp.text == hair_color:
                    hair_color = temp.xpath('@value')[0]
                    break

            jobGroup = self.lxlmldoc.xpath(
                '//*[@id="ModifyChar"]/table[4]/tr[7]/td[2]/text()')[0]
            if re.search("fighter", jobGroup, re.I):
                jobGroup = 0
            else:
                jobGroup = 1

            char_name = self.lxlmldoc.xpath(
                '//*[@id="briefCharacterView_charName"]')[0].text

            exp = self.lxlmldoc.xpath('//*[@id="txtHiddenExp"]')[0].value
            sp = self.lxlmldoc.xpath('//*[@id="txtHiddenSp"]')[0].value
            karma = self.lxlmldoc.xpath('//*[@id="txtHiddenAlign"]')[0].value
            pk = self.lxlmldoc.xpath('//*[@id="txtHiddenPk"]')[0].value
            pk_pardon = self.lxlmldoc.xpath(
                '//*[@id="txtHiddenPkPardon"]')[0].value
            duel = self.lxlmldoc.xpath('//*[@id="txtHiddenDuel"]')[0].value
            pre_olympiad = self.lxlmldoc.xpath(
                '//*[@id="txtHiddenpreOlympiad"]')[0].value
            cur_olympiad = self.lxlmldoc.xpath(
                '//*[@id="txtHiddencurOlympiad"]')[0].value
            PC_cafe_point = self.lxlmldoc.xpath(
                '//*[@id="txtHiddenPCcafepoint"]')[0].value
            fame = self.lxlmldoc.xpath('//*[@id="txtHiddenPvpPoint"]')[0].value
            vitality = self.lxlmldoc.xpath(
                '//*[@id="txtHiddenVitalityPoint"]')[0].value
            bot = self.lxlmldoc.xpath('//*[@id="txtHiddenBotPoint"]')[0].value

            return {
                "CharName": char_name,
                "gender": gender,
                "race": race,
                "cls": clazz,
                "face": face,
                "hairShape": hair_style,
                "hairColor": hair_color,
                "jobGroup": jobGroup,
                "hiddenOriginalExp": exp,
                "expDelta": exp,
                #                "DropDownListLevel": "0",
                "spDelta": sp,
                "alignDelta": karma,
                "pkDelta": pk,
                "pkPardonDelta": pk_pardon,
                "duelDelta": duel,
                "preOlympiadDelta": pre_olympiad,
                "curOlympiadDelta": cur_olympiad,
                "PCcafePointDelta": PC_cafe_point,
                "PvPPointDelta": fame,
                "vitalityPointDelta": vitality,
                "botPointDelta": bot,
                "modifyWay": "absolute",
                "update": "Request change",
                "txtHiddenExp": exp,
                "txtHiddenSp": sp,
                "txtHiddenAlign": karma,
                "txtHiddenPk": pk,
                "txtHiddenPkPardon": pk_pardon,
                "txtHiddenDuel": duel,
                "txtHiddenpreOlympiad": pre_olympiad,
                "txtHiddencurOlympiad": cur_olympiad,
                "txtHiddenPCcafepoint": PC_cafe_point,
                "txtHiddenPvpPoint": fame,
                "txtHiddenVitalityPoint": vitality,
                "txtHiddenBotPoint": bot
            }

        except Exception as e:
            print(e)
            raise InternalException(message="Internal error in parser!")
Beispiel #9
0
 def createUrl(self, params):
     url_base = Lineage2DefaultUrlCreator.createUrl(self, params)
     if "id" in params:
         return  url_base + "&id=" + (str)(params["id"])
     else:
         raise  InternalException(message="Id is required!")
Beispiel #10
0
 def createUrl(self, params):
     url_base =  Lineage2DefaultUrlCreator.createUrl(self, params)
     if "id" in params:
         return url_base + "&RequestId=" + (str)(params["id"]) + "&RetUrl=" + self.page.support.getBaseUrl()
     else:
         raise InternalException(message="Id is required!")
Beispiel #11
0
 def setFactory(factory):
     if not isinstance(factory, Factory):
         raise InternalException('It is not a factory!')
     Receiver.ReceiverFactory = factory
Beispiel #12
0
 def setFactory(factory):
     if not isinstance(factory, Factory):
         raise InternalException('It is not a factory!')
     UrlCreator.UrlCreatorFactory = factory
Beispiel #13
0
 def setFactory(factory):
     if not isinstance(factory, Factory):
         raise InternalException('It is not a factory!')
     Initializer.InitializerFactory = factory