コード例 #1
0
ファイル: Netsuite.py プロジェクト: mdp/rpaframework
    def login(
        self,
        account: str = None,
        email: str = None,
        password: str = None,
        role: str = None,
        appid: str = None,
    ) -> None:
        """Login to Netsuite with credentials from environment variables

        Parameters are not logged into Robot Framework log.

        :param account: parameter or environment variable `NS_ACCOUNT`
        :param email: parameter or environment variable `NS_EMAIL`
        :param password: parameter or environment variable `NS_PASSWORD`
        :param role: parameter or environment variable `NS_ROLE`
        :param appid: parameter or environment variable `NS_APPID`
        """
        if account is None:
            account = required_env("NS_ACCOUNT", self.account)
        if account is None:
            raise NetsuiteAuthenticationError("Authentication is not completed")
        NS_EMAIL = required_env("NS_EMAIL", email)
        NS_PASSWORD = required_env("NS_PASSWORD", password)
        NS_ROLE = required_env("NS_ROLE", role)
        NS_APPID = required_env("NS_APPID", appid)

        if self.client is None:
            self.client = NetSuiteClient(account=account)
        self.client.login(
            email=NS_EMAIL, password=NS_PASSWORD, role=NS_ROLE, application_id=NS_APPID,
        )
コード例 #2
0
ファイル: Twitter.py プロジェクト: acrofrank/rpa-framework
    def authorize(
        self,
        consumer_key: str = None,
        consumer_secret: str = None,
        access_token: str = None,
        access_token_secret: str = None,
    ) -> None:
        """Authorize to Twitter API

        :param consumer_key: app consumer key
        :param consumer_secret: app consumer secret
        :param access_token: user access token
        :param access_token_secret: user access token secret
        """
        consumer_key = required_env("TWITTER_CONSUMER_KEY", consumer_key)
        consumer_secret = required_env("TWITTER_CONSUMER_SECRET",
                                       consumer_secret)
        access_token = required_env("TWITTER_ACCESS_TOKEN", access_token)
        access_token_secret = required_env("TWITTER_ACCESS_TOKEN_SECRET",
                                           access_token_secret)
        self._auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
        self._auth.set_access_token(access_token, access_token_secret)
        self.api = tweepy.API(self._auth, wait_on_rate_limit=True)
        try:
            self.api.verify_credentials()
            self.logger.info("Twitter authentication success")
            self._me = self.api.me()
        except TweepError as e:
            self.logger.error("Error during Twitter authentication: %s",
                              str(e))
コード例 #3
0
ファイル: Netsuite.py プロジェクト: mdp/rpaframework
    def connect(
        self,
        account: str = None,
        consumer_key: str = None,
        consumer_secret: str = None,
        token_key: str = None,
        token_secret: str = None,
    ) -> None:
        """ Connect to Netsuite with credentials from environment
        variables.

        Parameters are not logged into Robot Framework log.

        :param account: parameter or environment variable `NS_ACCOUNT`
        :param consumer_key:  parameter or environment variable `NS_CONSUMER_KEY`
        :param consumer_secret: parameter or environment variable `NS_CONSUMER_SECRET`
        :param token_key: parameter or environment variable `NS_TOKEN_KEY`
        :param token_secret: parameter or environment variable `NS_TOKEN_SECRET`
        """
        if account is None:
            self.account = required_env("NS_ACCOUNT")
        else:
            self.account = account

        NS_CONSUMER_KEY = required_env("NS_CONSUMER_KEY", consumer_key)
        NS_CONSUMER_SECRET = required_env("NS_CONSUMER_SECRET", consumer_secret)
        NS_TOKEN_KEY = required_env("NS_TOKEN_KEY", token_key)
        NS_TOKEN_SECRET = required_env("NS_TOKEN_SECRET", token_secret)
        self.client = NetSuiteConnection(
            account=self.account,
            consumer_key=NS_CONSUMER_KEY,
            consumer_secret=NS_CONSUMER_SECRET,
            token_key=NS_TOKEN_KEY,
            token_secret=NS_TOKEN_SECRET,
        )
コード例 #4
0
    def load_work_item_from_environment(self):
        """Load current work item defined by the runtime environment.

        The corresponding environment variables are:

        * RC_WORKSPACE_ID
        * RC_WORKITEM_ID
        """
        workspace_id = required_env("RC_WORKSPACE_ID")
        item_id = required_env("RC_WORKITEM_ID")
        self.load_work_item(workspace_id, item_id)
コード例 #5
0
 def _load_adapter(self, default):
     """Load adapter by name, using env or given default."""
     adapter = required_env("RPA_WORKITEMS_ADAPTER", default)
     if isinstance(adapter, str):
         self.adapter = import_by_name(adapter, __name__)
     else:
         self.adapter = adapter
     assert issubclass(
         self.adapter,
         BaseAdapter), "Adapter does not inherit from BaseAdapter"
コード例 #6
0
ファイル: AWS.py プロジェクト: mdp/rpaframework
 def _init_client(
     self,
     service_name: str,
     aws_key_id: str = None,
     aws_key: str = None,
     region: str = None,
 ):
     if region is None:
         region = self.region
     if aws_key_id is None:
         aws_key_id = required_env("AWS_KEY_ID")
     if aws_key is None:
         aws_key = required_env("AWS_KEY")
     client = boto3.client(
         service_name,
         region_name=region,
         aws_access_key_id=aws_key_id,
         aws_secret_access_key=aws_key,
     )
     self._set_service(service_name, client)
コード例 #7
0
 def __init__(self):
     self.host = required_env("RC_API_WORKITEM_HOST")
     self.token = required_env("RC_API_WORKITEM_TOKEN")
コード例 #8
0
 def __init__(self):
     self.path = required_env("RPA_WORKITEMS_PATH")