Exemple #1
0
 def __init__(self, *args, **kwargs):
     appier.Api.__init__(self, *args, **kwargs)
     self.username = appier.conf("TT_USERNAME", None)
     self.password = appier.conf("TT_PASSWORD", None)
     self.base_url = kwargs.get("base_url", BASE_URL)
     self.username = kwargs.get("username", self.username)
     self.password = kwargs.get("password", self.password)
Exemple #2
0
    def loop(self):
        logging.basicConfig(level = logging.DEBUG)

        base_url = appier.conf("BASE_URL", BASE_URL)
        secret_key = appier.conf("SECRET_KEY", None)
        node_id = appier.conf("NODE_ID", "node")
        node_name = appier.conf("NODE_NAME", "node")
        node_location = appier.conf("NODE_LOCATION", "undefined")

        headers = dict()
        if secret_key: headers["X-Secret-Key"] = secret_key

        while True:
            try:
                logging.info("Submitting node information")
                appier.post(
                    base_url + "nodes/%s" % node_id,
                    data_j = dict(
                        name = node_name,
                        location = node_location
                    ),
                    headers = headers
                )
                logging.info("Retrieving jobs for node '%s'" % node_id)
                jobs = appier.get(
                    base_url + "nodes/%s/jobs" % node_id,
                    headers = headers,
                    timeout = 600
                )
                logging.info("Retrieved %d jobs for node '%s'" % (len(jobs), node_id))
                for job in jobs: self.print_job(job)
            except BaseException as exception:
                logging.info("Exception while looping '%s'" % str(exception))
                logging.info("Sleeping for %.2f seconds" % self.sleep_time)
                time.sleep(self.sleep_time)
Exemple #3
0
 def has_twitter(self):
     try: import twitter
     except Exception: twitter = None
     if not twitter: return False
     if not appier.conf("TWITTER_KEY"): return False
     if not appier.conf("TWITTER_SECRET"): return False
     return True
Exemple #4
0
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.api_key = appier.conf("NEXMO_API_KEY", None)
     self.api_secret = appier.conf("NEXMO_API_SECRET", None)
     self.base_url = kwargs.get("base_url", BASE_URL)
     self.api_key = kwargs.get("api_key", self.api_key)
     self.api_secret = kwargs.get("api_secret", self.api_secret)
Exemple #5
0
def get_api():
    return shopify.API(
        api_key = appier.conf("SHOPIFY_API_KEY"),
        password = appier.conf("SHOPIFY_PASSWORD"),
        secret = appier.conf("SHOPIFY_SECRET"),
        store_url = appier.conf("SHOPIFY_STORE")
    )
Exemple #6
0
def get_api():
    return google.API(
        client_id = appier.conf("GOOGLE_ID"),
        client_secret = appier.conf("GOOGLE_SECRET"),
        redirect_url = appier.conf("GOOGLE_REDIRECT_URL"),
        scope = SCOPE
    )
Exemple #7
0
 def load_shopify(self):
     self.shopify = shopify.Api(
         api_key = appier.conf("SHOPIFY_API_KEY"),
         password = appier.conf("SHOPIFY_PASSWORD"),
         secret = appier.conf("SHOPIFY_SECRET"),
         store_url = appier.conf("SHOPIFY_STORE")
     )
Exemple #8
0
def get_api(api_class = easypay.ShelveApi):
    return api_class(
        username = appier.conf("EASYPAY_USERNAME"),
        password = appier.conf("EASYPAY_PASSWORD"),
        cin = appier.conf("EASYPAY_CIN"),
        entity = appier.conf("EASYPAY_ENTITY")
    )
 def has_live(self):
     try: import live
     except Exception: live = None
     if not live: return False
     if not appier.conf("LIVE_ID"): return False
     if not appier.conf("LIVE_SECRET"): return False
     return True
 def has_facebook(self):
     try: import facebook
     except Exception: facebook = None
     if not facebook: return False
     if not appier.conf("FB_ID"): return False
     if not appier.conf("FB_SECRET"): return False
     return True
Exemple #11
0
 def has_google(self):
     try: import google
     except: google = None
     if not google: return False
     if not appier.conf("GOOGLE_ID"): return False
     if not appier.conf("GOOGLE_SECRET"): return False
     return True
 def has_twitter(self):
     try: import twitter
     except Exception: twitter = None
     if not twitter: return False
     if not appier.conf("TWITTER_KEY"): return False
     if not appier.conf("TWITTER_SECRET"): return False
     return True
Exemple #13
0
def get_api():
    return shopify.API(
        api_key = appier.conf("SHOPIFY_API_KEY"),
        password = appier.conf("SHOPIFY_PASSWORD"),
        secret = appier.conf("SHOPIFY_SECRET"),
        store_url = appier.conf("SHOPIFY_STORE")
    )
Exemple #14
0
 def has_github(self):
     try: import github
     except Exception: github = None
     if not github: return False
     if not appier.conf("GITHUB_ID"): return False
     if not appier.conf("GITHUB_SECRET"): return False
     return True
Exemple #15
0
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.domain = appier.conf("ZD_DOMAIN", DOMAIN)
     self.username = appier.conf("ZD_USERNAME", None)
     self.token = appier.conf("ZD_TOKEN", None)
     self.username = kwargs.get("username", self.username)
     self.token = kwargs.get("token", self.token)
     self.base_url = "https://%s/api/v2/" % self.domain
Exemple #16
0
def get_api():
    return github.API(
        username = appier.conf("GITHUB_USERNAME"),
        password = appier.conf("GITHUB_PASSWORD"),
        client_id = appier.conf("GITHUB_ID"),
        client_secret = appier.conf("GITHUB_SECRET"),
        redirect_url = appier.conf("GITHUB_REDIRECT_URL")
    )
Exemple #17
0
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.base_url = appier.conf("DOCKER_BASE_URL", BASE_URL)
     self.username = appier.conf("DOCKER_USERNAME", None)
     self.password = appier.conf("DOCKER_PASSWORD", None)
     self.base_url = kwargs.get("base_url", self.base_url)
     self.username = kwargs.get("username", self.username)
     self.password = kwargs.get("password", self.password)
Exemple #18
0
 def __init__(self, *args, **kwargs):
     appier.Api.__init__(self, *args, **kwargs)
     self.domain = appier.conf("ZD_DOMAIN", DOMAIN)
     self.username = appier.conf("ZD_USERNAME", None)
     self.token = appier.conf("ZD_TOKEN", None)
     self.username = kwargs.get("username", self.username)
     self.token = kwargs.get("token", self.token)
     self.base_url = "https://%s/api/v2/" % self.domain
Exemple #19
0
 def get_api(self):
     if self._api: return self._api
     self._api = omni.Api(
         base_url = appier.conf("OMNI_BASE_URL"),
         username = appier.conf("OMNI_USERNAME"),
         password = appier.conf("OMNI_PASSWORD")
     )
     return self._api
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.base_url = appier.conf("ALIYUN_BASE_URL", BASE_URL)
     self.access_key = appier.conf("ALIYUN_ACCESS_KEY", None)
     self.secret = appier.conf("ALIYUN_SECRET", None)
     self.base_url = kwargs.get("base_url", self.base_url)
     self.access_key = kwargs.get("access_key", self.access_key)
     self.secret = kwargs.get("secret", self.secret)
     self.bucket_url = self.base_url.replace("https://", "https://%s.")
Exemple #21
0
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.sid = appier.conf("TWILIO_SID", None)
     self.auth_token = appier.conf("TWILIO_AUTH_TOKEN", None)
     self.base_url = kwargs.get("base_url", BASE_URL)
     self.base_template = kwargs.get("base_template", BASE_TEMPLATE)
     self.sid = kwargs.get("sid", self.sid)
     self.auth_token = kwargs.get("auth_token", self.auth_token)
     self._build_url()
Exemple #22
0
 def has_live(self):
     try:
         import live
     except Exception:
         live = None
     if not live: return False
     if not appier.conf("LIVE_ID"): return False
     if not appier.conf("LIVE_SECRET"): return False
     return True
Exemple #23
0
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.sid = appier.conf("TWILIO_SID", None)
     self.auth_token = appier.conf("TWILIO_AUTH_TOKEN", None)
     self.base_url = kwargs.get("base_url", BASE_URL)
     self.base_template = kwargs.get("base_template", BASE_TEMPLATE)
     self.sid = kwargs.get("sid", self.sid)
     self.auth_token = kwargs.get("auth_token", self.auth_token)
     self._build_url()
Exemple #24
0
 def has_google(self):
     try:
         import google
     except Exception:
         google = None
     if not google: return False
     if not appier.conf("GOOGLE_ID"): return False
     if not appier.conf("GOOGLE_SECRET"): return False
     return True
Exemple #25
0
    def test_none(self):
        appier.conf_s("AGE", None)
        result = appier.conf("AGE", cast = int)

        self.assertEqual(result, None)

        result = appier.conf("HEIGHT", cast = int)

        self.assertEqual(result, None)
Exemple #26
0
 def core_url(self):
     ripe_suffix = appier.conf("RIPE_SUFFIX", None)
     if ripe_suffix:
         core_url = "https://ripe-core-%s.platforme.com" % ripe_suffix
     else:
         core_url = "http://localhost:8080"
     core_url = appier.conf("CORE_URL", core_url)
     core_url = appier.conf("RIPE_CORE_URL", core_url)
     return core_url
Exemple #27
0
 def has_facebook(self):
     try:
         import facebook
     except Exception:
         facebook = None
     if not facebook: return False
     if not appier.conf("FB_ID"): return False
     if not appier.conf("FB_SECRET"): return False
     return True
Exemple #28
0
    def test_none(self):
        appier.conf_s("AGE", None)
        result = appier.conf("AGE", cast = int)

        self.assertEqual(result, None)

        result = appier.conf("HEIGHT", cast = int)

        self.assertEqual(result, None)
Exemple #29
0
 def __init__(self, *args, **kwargs):
     base.Bot.__init__(self, *args, **kwargs)
     self.enabled = appier.conf("OMNI_BOT_ENABLED", False, cast = bool)
     self.store = appier.conf("OMNI_BOT_STORE", None, cast = int)
     self.records = appier.conf("OMNI_BOT_RECORDS", RECORDS)
     self.enabled = kwargs.get("enabled", self.enabled)
     self.store = kwargs.get("store", self.store)
     self.records = kwargs.get("records", self.records)
     self.api = None
Exemple #30
0
 def __init__(self, *args, **kwargs):
     appier.OAuth2API.__init__(self, *args, **kwargs)
     self.sandbox = appier.conf("PAYPAL_SANDBOX", True, cast=bool)
     self.client_id = appier.conf("PAYPAL_ID", CLIENT_ID)
     self.client_secret = appier.conf("PAYPAL_SECRET", CLIENT_SECRET)
     self.base_url = kwargs.get("base_url",
                                SANDBOX_URL if self.sandbox else BASE_URL)
     self.client_id = kwargs.get("client_id", self.client_id)
     self.client_secret = kwargs.get("client_secret", self.client_secret)
     self.access_token = kwargs.get("access_token", None)
Exemple #31
0
 def load_easypay(self):
     self.easypay = easypay.ShelveApi(
         production = appier.conf("EASYPAY_PRODUCTION", cast = bool),
         username = appier.conf("EASYPAY_USERNAME"),
         password = appier.conf("EASYPAY_PASSWORD"),
         cin = appier.conf("EASYPAY_CIN"),
         entity = appier.conf("EASYPAY_ENTITY")
     )
     self.easypay.bind("paid", self.on_paid)
     self.easypay.start_scheduler()
Exemple #32
0
 def pulse_url(self):
     ripe_suffix = appier.conf("RIPE_SUFFIX", None)
     if ripe_suffix:
         pulse_url = "https://ripe-pulse-%s.platforme.com" % ripe_suffix
     else:
         pulse_url = "http://localhost:3000"
     pulse_url = appier.conf("BASE_URL", pulse_url)
     pulse_url = appier.conf("PULSE_URL", pulse_url)
     pulse_url = appier.conf("RIPE_PULSE_URL", pulse_url)
     return pulse_url
Exemple #33
0
 def retail_url(self):
     ripe_suffix = appier.conf("RIPE_SUFFIX", None)
     if ripe_suffix:
         retail_url = "https://ripe-retail-%s.platforme.com" % ripe_suffix
     else:
         retail_url = "http://localhost:8080"
     retail_url = appier.conf("BASE_URL", retail_url)
     retail_url = appier.conf("RETAIL_URL", retail_url)
     retail_url = appier.conf("RIPE_RETAIL_URL", retail_url)
     return retail_url
Exemple #34
0
 def __init__(self, *args, **kwargs):
     appier.Part.__init__(self, *args, **kwargs)
     self.log = kwargs.get("log", False)
     self.buffer_size = kwargs.get("buffer_size", 128)
     self.timeout = kwargs.get("timeout", 30)
     self.log = appier.conf("LOGGLY_LOG", self.log, cast=bool)
     self.buffer_size = appier.conf("LOGGLY_BUFFER_SIZE",
                                    self.buffer_size,
                                    cast=int)
     self.timeout = appier.conf("LOGGLY_TIMEOUT", self.timeout, cast=int)
Exemple #35
0
 def white_url(self):
     ripe_suffix = appier.conf("RIPE_SUFFIX", None)
     if ripe_suffix:
         white_url = "https://ripe-white-%s.platforme.com" % ripe_suffix
     else:
         white_url = "http://localhost:3000"
     white_url = appier.conf("BASE_URL", white_url)
     white_url = appier.conf("WHITE_URL", white_url)
     white_url = appier.conf("RIPE_WHITE_URL", white_url)
     return white_url
Exemple #36
0
 def __init__(self, *args, **kwargs):
     appier.OAuth2API.__init__(self, *args, **kwargs)
     self.base_url = appier.conf("OMNI_BASE_URL", BASE_URL)
     self.open_url = appier.conf("OMNI_OPEN_URL", self.base_url)
     self.prefix = appier.conf("OMNI_PREFIX", "adm/")
     self.client_id = appier.conf("OMNI_ID", CLIENT_ID)
     self.client_secret = appier.conf("OMNI_SECRET", CLIENT_SECRET)
     self.redirect_url = appier.conf("OMNI_REDIRECT_URL", REDIRECT_URL)
     self.scope = appier.conf("OMNI_SCOPE", SCOPE)
     self.username = appier.conf("OMNI_USERNAME", None)
     self.password = appier.conf("OMNI_PASSWORD", None)
     self.base_url = kwargs.get("base_url", self.base_url)
     self.open_url = kwargs.get("open_url", self.open_url)
     self.prefix = kwargs.get("prefix", self.prefix)
     self.client_id = kwargs.get("client_id", self.client_id)
     self.client_secret = kwargs.get("client_secret", self.client_secret)
     self.redirect_url = kwargs.get("redirect_url", self.redirect_url)
     self.scope = kwargs.get("scope", self.scope)
     self.access_token = kwargs.get("access_token", None)
     self.session_id = kwargs.get("session_id", None)
     self.username = kwargs.get("username", self.username)
     self.password = kwargs.get("password", self.password)
     self.object_id = kwargs.get("object_id", None)
     self.acl = kwargs.get("acl", None)
     self.tokens = kwargs.get("tokens", None)
     self.company = kwargs.get("company", None)
     self.wrap_exception = kwargs.get("wrap_exception", True)
     self.mode = kwargs.get("mode", None) or self._get_mode()
Exemple #37
0
 def __init__(self, *args, **kwargs):
     appier.OAuth1Api.__init__(self, *args, **kwargs)
     self.client_key = appier.conf("TWITTER_KEY", CLIENT_KEY)
     self.client_secret = appier.conf("TWITTER_SECRET", CLIENT_SECRET)
     self.redirect_url = appier.conf("TWITTER_REDIRECT_URL", REDIRECT_URL)
     self.base_url = kwargs.get("base_url", BASE_URL)
     self.client_key = kwargs.get("client_key", self.client_key)
     self.client_secret = kwargs.get("client_secret", self.client_secret)
     self.redirect_url = kwargs.get("redirect_url", self.redirect_url)
     self.oauth_token = kwargs.get("oauth_token", None)
     self.oauth_token_secret = kwargs.get("oauth_token_secret", None)
 def _get_contentful_cache(cls, serialize = True, ref = None):
     ref = ref or Contentful
     if ref._contentful_cache: return ref._contentful_cache
     cache_engine = appier.conf("CACHE", "memory")
     cache_engine = appier.conf("CMS_CACHE_ENGINE", cache_engine)
     cache_engine = appier.conf("CONTENTFUL_CACHE_ENGINE", cache_engine)
     cache_engine = cache_engine.capitalize() + "Cache"
     cache_engine = getattr(appier, cache_engine)
     ref._contentful_cache = cache_engine.new(hash = True)
     if serialize: ref._contentful_cache = appier.SerializedCache(cls._contentful_cache)
     return ref._contentful_cache
Exemple #39
0
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.repo = appier.conf("PRISMIC_REPO", None)
     self.ref = appier.conf("PRISMIC_REF", None)
     self.token = appier.conf("PRISMIC_TOKEN", None)
     self.base_url = kwargs.get("base_url", BASE_URL)
     self.repo = kwargs.get("repo", self.repo)
     self.ref = kwargs.get("ref", self.ref)
     self.token = kwargs.get("token", self.token)
     self._build_url()
     self._ensure_ref()
Exemple #40
0
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.app_id = appier.conf("PUSHI_ID", None)
     self.app_key = appier.conf("PUSHI_KEY", None)
     self.app_secret = appier.conf("PUSHI_SECRET", None)
     self.base_url = appier.conf("PUSHI_URL", BASE_URL)
     self.app_id = kwargs.get("app_id", self.app_id)
     self.app_key = kwargs.get("app_key", self.app_key)
     self.app_secret = kwargs.get("app_secret", self.app_secret)
     self.base_url = kwargs.get("base_url", self.base_url)
     self.token = None
Exemple #41
0
 def get_twitter_api(self):
     import twitter
     redirect_url = self.url_for("admin.oauth_twitter", absolute=True)
     oauth_token = self.session and self.session.get("tw.oauth_token", None)
     oauth_token_secret = self.session and self.session.get(
         "tw.oauth_token_secret", None)
     return twitter.API(client_key=appier.conf("TWITTER_KEY"),
                        client_secret=appier.conf("TWITTER_SECRET"),
                        redirect_url=redirect_url,
                        oauth_token=oauth_token,
                        oauth_token_secret=oauth_token_secret)
Exemple #42
0
 def __init__(self, *args, **kwargs):
     appier.OAuth1API.__init__(self, *args, **kwargs)
     self.client_key = appier.conf("TWITTER_KEY", CLIENT_KEY)
     self.client_secret = appier.conf("TWITTER_SECRET", CLIENT_SECRET)
     self.redirect_url = appier.conf("TWITTER_REDIRECT_URL", REDIRECT_URL)
     self.base_url = kwargs.get("base_url", BASE_URL)
     self.client_key = kwargs.get("client_key", self.client_key)
     self.client_secret = kwargs.get("client_secret", self.client_secret)
     self.redirect_url = kwargs.get("redirect_url", self.redirect_url)
     self.oauth_token = kwargs.get("oauth_token", None)
     self.oauth_token_secret = kwargs.get("oauth_token_secret", None)
Exemple #43
0
 def __init__(self, *args, **kwargs):
     appier.OAuth2API.__init__(self, *args, **kwargs)
     self.client_id = appier.conf("FB_ID", CLIENT_ID)
     self.client_secret = appier.conf("FB_SECRET", CLIENT_SECRET)
     self.redirect_url = appier.conf("FB_REDIRECT_URL", REDIRECT_URL)
     self.base_url = kwargs.get("base_url", BASE_URL)
     self.client_id = kwargs.get("client_id", self.client_id)
     self.client_secret = kwargs.get("client_secret", self.client_secret)
     self.redirect_url = kwargs.get("redirect_url", self.redirect_url)
     self.scope = kwargs.get("scope", SCOPE)
     self.access_token = kwargs.get("access_token", None)
 def _get_prismic_cache(cls, serialize = True, ref = None):
     ref = ref or Prismic
     if ref._prismic_cache: return ref._prismic_cache
     cache_engine = appier.conf("CACHE", "memory")
     cache_engine = appier.conf("CMS_CACHE_ENGINE", cache_engine)
     cache_engine = appier.conf("PRISMIC_CACHE_ENGINE", cache_engine)
     cache_engine = cache_engine.capitalize() + "Cache"
     cache_engine = getattr(appier, cache_engine)
     ref._prismic_cache = cache_engine.new(hash = True)
     if serialize: ref._prismic_cache = appier.SerializedCache(cls._prismic_cache)
     return ref._prismic_cache
 def _get_prismic_cache(cls, serialize = True, ref = None):
     ref = ref or Prismic
     if ref._prismic_cache: return ref._prismic_cache
     cache_engine = appier.conf("CACHE", "memory")
     cache_engine = appier.conf("CMS_CACHE_ENGINE", cache_engine)
     cache_engine = appier.conf("PRISMIC_CACHE_ENGINE", cache_engine)
     cache_engine = cache_engine.capitalize() + "Cache"
     cache_engine = getattr(appier, cache_engine)
     ref._prismic_cache = cache_engine.new(hash = True)
     if serialize: ref._prismic_cache = appier.SerializedCache(cls._prismic_cache)
     return ref._prismic_cache
Exemple #46
0
def recaptcha_ensure(self, token, action="default", force=False):
    if not _recaptcha_available() and not force: return
    secret = appier.conf("RECAPTCHA_SECRET", None)
    min_score = appier.conf("RECAPTCHA_MIN", 0.5)
    result = appier.post("https://www.google.com/recaptcha/api/siteverify",
                         params=dict(secret=secret, response=token))
    if result.get("score", 0) >= min_score and\
        result.get("action", None) == action:
        return token
    raise appier.AppierException(message="Invalid reCAPTCHA score or action",
                                 code=403)
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.base_url = appier.conf("ADMIN_URL", BASE_URL)
     self.username = appier.conf("ADMIN_USERNAME", None)
     self.password = appier.conf("ADMIN_PASSWORD", None)
     self.secret_key = appier.conf("ADMIN_SECRET_KEY", None)
     self.base_url = kwargs.get("base_url", self.base_url)
     self.username = kwargs.get("username", self.username)
     self.password = kwargs.get("password", self.password)
     self.secret_key = kwargs.get("secret_key", self.secret_key)
     self.session_id = kwargs.get("session_id", None)
Exemple #48
0
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.app_id = appier.conf("PUSHI_ID", None)
     self.app_key = appier.conf("PUSHI_KEY", None)
     self.app_secret = appier.conf("PUSHI_SECRET", None)
     self.base_url = appier.conf("PUSHI_URL", BASE_URL)
     self.app_id = kwargs.get("app_id", self.app_id)
     self.app_key = kwargs.get("app_key", self.app_key)
     self.app_secret = kwargs.get("app_secret", self.app_secret)
     self.base_url = kwargs.get("base_url", self.base_url)
     self.token = None
Exemple #49
0
 def get_live_api(self):
     try:
         import live
     except Exception:
         return None
     if not self.live_token: return None
     redirect_url = self.owner.url_for("admin.oauth_live", absolute=True)
     access_token = self.live_token
     return live.API(client_id=appier.conf("LIVE_ID"),
                     client_secret=appier.conf("LIVE_SECRET"),
                     redirect_url=redirect_url,
                     access_token=access_token)
Exemple #50
0
 def __init__(self, *args, **kwargs):
     appier.OAuth2API.__init__(self, *args, **kwargs)
     self.client_id = appier.conf("INSTAGRAM_ID", CLIENT_ID)
     self.client_secret = appier.conf("INSTAGRAM_SECRET", CLIENT_SECRET)
     self.redirect_url = appier.conf("INSTAGRAM_REDIRECT_URL", REDIRECT_URL)
     self.base_url = kwargs.get("base_url", BASE_URL)
     self.client_id = kwargs.get("client_id", self.client_id)
     self.client_secret = kwargs.get("client_secret", self.client_secret)
     self.redirect_url = kwargs.get("redirect_url", self.redirect_url)
     self.scope = kwargs.get("scope", SCOPE)
     self.access_token = kwargs.get("access_token", None)
     self.user_id = kwargs.get("user_id", None)
Exemple #51
0
 def get_facebook_api(self, scope=None):
     import facebook
     kwargs = dict()
     redirect_url = self.url_for("admin.oauth_facebook", absolute=True)
     access_token = self.session and self.session.get(
         "fb.access_token", None)
     if scope: kwargs["scope"] = scope
     return facebook.API(client_id=appier.conf("FB_ID"),
                         client_secret=appier.conf("FB_SECRET"),
                         redirect_url=redirect_url,
                         access_token=access_token,
                         **kwargs)
 def get_github_api(self, scope=None):
     import github
     kwargs = dict()
     redirect_url = self.url_for("admin.oauth_github", absolute=True)
     access_token = self.session and self.session.get(
         "gh.access_token", None)
     if scope: kwargs["scope"] = scope
     return github.API(client_id=appier.conf("GITHUB_ID"),
                       client_secret=appier.conf("GITHUB_SECRET"),
                       redirect_url=redirect_url,
                       access_token=access_token,
                       **kwargs)
Exemple #53
0
 def get_github_api(self):
     try:
         import github
     except Exception:
         return None
     if not self.github_token: return None
     redirect_url = self.owner.url_for("admin.oauth_github", absolute=True)
     access_token = self.github_token
     return github.API(client_id=appier.conf("GITHUB_ID"),
                       client_secret=appier.conf("GITHUB_SECRET"),
                       redirect_url=redirect_url,
                       access_token=access_token)
Exemple #54
0
 def get_facebook_api(self):
     try: import facebook
     except: return None
     if not self.facebook_token: return None
     redirect_url = self.owner.url_for("admin.oauth_facebook", absolute = True)
     access_token = self.facebook_token
     return facebook.Api(
         client_id = appier.conf("FB_ID"),
         client_secret = appier.conf("FB_SECRET"),
         redirect_url = redirect_url,
         access_token = access_token
     )
Exemple #55
0
 def __init__(self, *args, **kwargs):
     appier.API.__init__(self, *args, **kwargs)
     self.base_url = appier.conf("BINANCE_BASE_URL", BASE_URL)
     self.neo_url = appier.conf("BINANCE_NEO_URL", NEO_URL)
     self.wapi_url = appier.conf("BINANCE_WAPI_URL", WAPI_URL)
     self.api_key = appier.conf("BINANCE_API_KEY", None)
     self.secret = appier.conf("BINANCE_SECRET", None)
     self.base_url = kwargs.get("base_url", self.base_url)
     self.neo_url = kwargs.get("neo_url", self.neo_url)
     self.wapi_url = kwargs.get("wapi_url", self.wapi_url)
     self.api_key = kwargs.get("api_key", self.api_key)
     self.secret = kwargs.get("secret", self.secret)
Exemple #56
0
 def get_github_api(self):
     try: import github
     except: return None
     if not self.github_token: return None
     redirect_url = self.owner.url_for("admin.oauth_github", absolute = True)
     access_token = self.github_token
     return github.Api(
         client_id = appier.conf("GITHUB_ID"),
         client_secret = appier.conf("GITHUB_SECRET"),
         redirect_url = redirect_url,
         access_token = access_token
     )
Exemple #57
0
 def get_live_api(self):
     try: import live
     except: return None
     if not self.live_token: return None
     redirect_url = self.owner.url_for("admin.oauth_live", absolute = True)
     access_token = self.live_token
     return live.Api(
         client_id = appier.conf("LIVE_ID"),
         client_secret = appier.conf("LIVE_SECRET"),
         redirect_url = redirect_url,
         access_token = access_token
     )
 def get_twitter_api(self):
     import twitter
     redirect_url = self.url_for("admin.oauth_twitter", absolute = True)
     oauth_token = self.session and self.session.get("tw.oauth_token", None)
     oauth_token_secret = self.session and self.session.get("tw.oauth_token_secret", None)
     return twitter.API(
         client_key = appier.conf("TWITTER_KEY"),
         client_secret = appier.conf("TWITTER_SECRET"),
         redirect_url = redirect_url,
         oauth_token = oauth_token,
         oauth_token_secret = oauth_token_secret
     )
Exemple #59
0
 def ensure_auth(self):
     username = appier.conf("REPO_USERNAME", None)
     password = appier.conf("REPO_PASSWORD", None)
     if not username: return
     authorization = self.request.authorization
     is_valid = authorization == (username, password)
     if not is_valid: raise appier.SecurityError(
         message = "Authentication failed",
         code = 401,
         headers = {
             "WWW-Authenticate" : "Basic realm=\"default\""
         }
     )