コード例 #1
0
ファイル: base.py プロジェクト: hivesolutions/instashow
def get_api(access_token = None):
    api = instagram.API(
        client_id = quorum.conf("INSTAGRAM_ID"),
        client_secret = quorum.conf("INSTAGRAM_SECRET"),
        redirect_url = quorum.conf("INSTAGRAM_REDIRECT_URL")
    )
    if access_token: api.access_token = access_token
    return api
コード例 #2
0
    def test_none(self):
        quorum.confs("AGE", None)
        result = quorum.conf("AGE", cast = int)

        self.assertEqual(result, None)

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

        self.assertEqual(result, None)
コード例 #3
0
ファイル: config.py プロジェクト: hivesolutions/flask_quorum
    def test_none(self):
        quorum.confs("AGE", None)
        result = quorum.conf("AGE", cast = int)

        self.assertEqual(result, None)

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

        self.assertEqual(result, None)
コード例 #4
0
ファイル: automium_web.py プロジェクト: netok99/DesafioPython
def run():
    # sets the debug control in the application
    # then checks the current environment variable
    # for the target port for execution (external)
    # and then start running it (continuous loop)
    debug = quorum.conf("DEBUG", False) and True or False
    reloader = quorum.conf("RELOADER", False) and True or False
    port = int(quorum.conf("PORT", 5000))
    app.debug = debug
    app.run(use_debugger=debug, debug=debug, use_reloader=reloader, host="0.0.0.0", port=port)
コード例 #5
0
ファイル: settings.py プロジェクト: hivesolutions/omnix
 def get_slack_api(self):
     try: import slack
     except ImportError: return None
     if not self.slack_token: return None
     redirect_url = util.BASE_URL + flask.url_for("oauth_slack")
     access_token = self.slack_token
     return slack.API(
         client_id = quorum.conf("SLACK_ID"),
         client_secret = quorum.conf("SLACK_SECRET"),
         redirect_url = redirect_url,
         access_token = access_token
     )
コード例 #6
0
ファイル: settings.py プロジェクト: hivesolutions/omnix
 def get_slack_api(self):
     try:
         import slack
     except ImportError:
         return None
     if not self.slack_token: return None
     redirect_url = util.BASE_URL + flask.url_for("oauth_slack")
     access_token = self.slack_token
     return slack.API(client_id=quorum.conf("SLACK_ID"),
                      client_secret=quorum.conf("SLACK_SECRET"),
                      redirect_url=redirect_url,
                      access_token=access_token)
コード例 #7
0
def run():
    # sets the debug control in the application
    # then checks the current environment variable
    # for the target port for execution (external)
    # and then start running it (continuous loop)
    debug = quorum.conf("DEBUG", False) and True or False
    reloader = quorum.conf("RELOADER", False) and True or False
    port = int(quorum.conf("PORT", 5000))
    app.debug = debug
    app.run(use_debugger=debug,
            debug=debug,
            use_reloader=reloader,
            host="0.0.0.0",
            port=port)
コード例 #8
0
ファイル: project.py プロジェクト: hivesolutions/mantium
 def get_folder(self):
     # retrieves the reference to the configuration value
     # containing the path the projects directory and uses
     # it to "compute" the path to the project directory
     projects_folder = quorum.conf("PROJECTS_FOLDER")
     project_folder = os.path.join(projects_folder, self.name)
     return project_folder
コード例 #9
0
 def get_folder(self):
     # retrieves the reference to the configuration value
     # containing the path the projects directory and uses
     # it to "compute" the path to the project directory
     projects_folder = quorum.conf("PROJECTS_FOLDER")
     project_folder = os.path.join(projects_folder, self.name)
     return project_folder
コード例 #10
0
    def test_basic(self):
        quorum.confs("NAME", "name")
        result = quorum.conf("NAME")

        self.assertEqual(result, "name")

        result = quorum.conf("NAME", cast = str)

        self.assertEqual(result, "name")
        self.assertEqual(type(result), str)

        result = quorum.conf("NAME", cast = "str")

        self.assertEqual(result, "name")
        self.assertEqual(type(result), str)

        quorum.confs("AGE", "10")
        result = quorum.conf("AGE", cast = int)

        self.assertEqual(result, 10)
        self.assertEqual(type(result), int)

        result = quorum.conf("AGE", cast = "int")

        self.assertEqual(result, 10)
        self.assertEqual(type(result), int)

        result = quorum.conf("AGE", cast = str)

        self.assertEqual(result, "10")
        self.assertEqual(type(result), str)

        result = quorum.conf("HEIGHT")

        self.assertEqual(result, None)
コード例 #11
0
ファイル: config.py プロジェクト: hivesolutions/flask_quorum
    def test_basic(self):
        quorum.confs("NAME", "name")
        result = quorum.conf("NAME")

        self.assertEqual(result, "name")

        result = quorum.conf("NAME", cast = str)

        self.assertEqual(result, "name")
        self.assertEqual(type(result), str)

        result = quorum.conf("NAME", cast = "str")

        self.assertEqual(result, "name")
        self.assertEqual(type(result), str)

        quorum.confs("AGE", "10")
        result = quorum.conf("AGE", cast = int)

        self.assertEqual(result, 10)
        self.assertEqual(type(result), int)

        result = quorum.conf("AGE", cast = "int")

        self.assertEqual(result, 10)
        self.assertEqual(type(result), int)

        result = quorum.conf("AGE", cast = str)

        self.assertEqual(result, "10")
        self.assertEqual(type(result), str)

        result = quorum.conf("HEIGHT")

        self.assertEqual(result, None)
コード例 #12
0
def print_image_posix(file_path):
    # retrieves a connection to the cups server and uses it to gather
    # the reference to the proper printer, then uses it to print the
    # image file directly as the printer is capable (as defined)
    printer = quorum.conf("PRINTER")
    connection = cups.Connection()
    printer_name = printer if printer else connection.getDefault()
    if not printer_name: raise RuntimeError("No default printer found")
    connection.printFile(printer_name, file_path, file_path, {})
コード例 #13
0
ファイル: printer.py プロジェクト: hivesolutions/instashow
def print_image_posix(file_path):
    # retrieves a connection to the cups server and uses it to gather
    # the reference to the proper printer, then uses it to print the
    # image file directly as the printer is capable (as defined)
    printer = quorum.conf("PRINTER")
    connection = cups.Connection()
    printer_name = printer if printer else connection.getDefault()
    if not printer_name: raise RuntimeError("No default printer found")
    connection.printFile(printer_name, file_path, file_path, {})
コード例 #14
0
ファイル: account.py プロジェクト: hivesolutions/pingu
    def sso_login(cls, id, timestamp, token, nav_data):
        # retrieves the various configuration properties
        # to be used for this operation
        salt_h = quorum.conf("salt_h", None)

        # re-creates the token from the provided id and timestamp
        # and the "secret" salt value
        _token = id + ":" + salt_h + ":" + timestamp
        _token = quorum.legacy.bytes(_token)
        _token_s = hashlib.sha1(_token).hexdigest()

        # retrieves the current time to be used in the timestamp
        # validation process
        current_time = time.time()

        # validation the token and then checks if the provided timestamp
        # is not defined in the past
        if not _token_s == token:
            raise quorum.OperationalError("Invalid token", code = 403)
        if not current_time < timestamp:
            return quorum.OperationalError("Invalid timestamp (in the past)", code = 403)

        # tries to retrieve the account associated with the provided
        # id value in case none is found returns in error
        account = Account.get(username = id, build = False, raise_e = False)
        if not account: return quorum.OperationalError("No user found", code = 403)

        # sets the login count and last login values in the account as the
        # current time and then saves it in the data store
        login_count = account.val("login_count", 0)
        account.login_count = login_count + 1
        account.last_login = time.time()
        account.save(account)

        # returns the account representing the user that has just been logged
        # in into the system to the caller method
        return account
コード例 #15
0
    def sso_login(cls, id, timestamp, token, nav_data):
        # retrieves the various configuration properties
        # to be used for this operation
        salt_h = quorum.conf("salt_h", None)

        # re-creates the token from the provided id and timestamp
        # and the "secret" salt value
        _token = id + ":" + salt_h + ":" + timestamp
        _token = quorum.legacy.bytes(_token)
        _token_s = hashlib.sha1(_token).hexdigest()

        # retrieves the current time to be used in the timestamp
        # validation process
        current_time = time.time()

        # validation the token and then checks if the provided timestamp
        # is not defined in the past
        if not _token_s == token:
            raise quorum.OperationalError("Invalid token", code = 403)
        if not current_time < timestamp:
            return quorum.OperationalError("Invalid timestamp (in the past)", code = 403)

        # tries to retrieve the account associated with the provided
        # id value in case none is found returns in error
        account = Account.get(username = id, build = False, raise_e = False)
        if not account: return quorum.OperationalError("No user found", code = 403)

        # sets the login count and last login values in the account as the
        # current time and then saves it in the data store
        login_count = account.val("login_count", 0)
        account.login_count = login_count + 1
        account.last_login = time.time()
        account.save(account)

        # returns the account representing the user that has just been logged
        # in into the system to the caller method
        return account
コード例 #16
0
def get_api(access_token=None):
    api = instagram.API(client_id=quorum.conf("INSTAGRAM_ID"),
                        client_secret=quorum.conf("INSTAGRAM_SECRET"),
                        redirect_url=quorum.conf("INSTAGRAM_REDIRECT_URL"))
    if access_token: api.access_token = access_token
    return api
コード例 #17
0
ファイル: sched.py プロジェクト: hivesolutions/instashow
def schedule_init():
    tag = quorum.conf("INSTAGRAM_SCHEDULE")
    if not tag: return
    quota = quorum.conf("INSTAGRAM_QUOTA", QUOTA_USER, cast = int)
    initial = quorum.conf("INSTAGRAM_INITIAL", 0, cast = int)
    schedule_tag(tag, quota = quota, initial = initial)
コード例 #18
0
)
""" The list containing the complete set of types that
are considered to be of type sake """

AT_TRANSPORT_TYPES = (
    "TransportationSlip",
    "ExpeditionSlip"
)
""" The list containing the complete set of types that
are considered to be of type transport """

AT_SUBMIT_TYPES = AT_SALE_TYPES + AT_TRANSPORT_TYPES
""" The set of valid types for submission to at, note
that this range of values should be changed with care """

REMOTE = quorum.conf("REMOTE", False)
BASE_URL = quorum.conf("BASE_URL", "http://*****:*****@omnix.com>")
USERNAME = quorum.conf("OMNIX_USERNAME", None)
PASSWORD = quorum.conf("OMNIX_PASSWORD", None)
SCHEDULE = quorum.conf("OMNIX_SCHEDULE", True, cast = bool)
COMMISSION_RATE = quorum.conf("OMNIX_COMMISSION_RATE", 0.01, cast = float)
COMMISSION_DAY = quorum.conf("OMNIX_COMMISSION_DAY", 26, cast = int)
IMAGE_RESIZE = quorum.conf("OMNIX_IMAGE_RESIZE", "crop")
LOCALE = quorum.conf("OMNIX_LOCALE", "en_us")

OMNI_URL = REMOTE_URL if REMOTE else LOCAL_URL
PREFIX = REMOTE_PREFIX if REMOTE else LOCAL_PREFIX
コード例 #19
0
ファイル: sched.py プロジェクト: hivesolutions/instashow
def schedule_init():
    tag = quorum.conf("INSTAGRAM_SCHEDULE")
    if not tag: return
    quota = quorum.conf("INSTAGRAM_QUOTA", QUOTA_USER, cast=int)
    initial = quorum.conf("INSTAGRAM_INITIAL", 0, cast=int)
    schedule_tag(tag, quota=quota, initial=initial)
コード例 #20
0
 def setUp(self):
     quorum.TestCase.setUp(self)
     self.httpbin = quorum.conf("HTTPBIN", "httpbin.org")
コード例 #21
0
ファイル: config.py プロジェクト: hivesolutions/omnix
""" The list of permissions to be used to create the
scope string for the OAuth value """

AT_SALE_TYPES = ("MoneySaleSlip", "Invoice", "CreditNote", "DebitNote")
""" The list containing the complete set of types that
are considered to be of type sake """

AT_TRANSPORT_TYPES = ("TransportationSlip", "ExpeditionSlip")
""" The list containing the complete set of types that
are considered to be of type transport """

AT_SUBMIT_TYPES = AT_SALE_TYPES + AT_TRANSPORT_TYPES
""" The set of valid types for submission to at, note
that this range of values should be changed with care """

REMOTE = quorum.conf("REMOTE", False, cast=bool)
REMOTE = quorum.conf("OMNIX_REMOTE", REMOTE, cast=bool)
BASE_URL = quorum.conf("BASE_URL", "http://*****:*****@omnix.com>")
USERNAME = quorum.conf("OMNIX_USERNAME", None)
PASSWORD = quorum.conf("OMNIX_PASSWORD", None)
SCHEDULE = quorum.conf("OMNIX_SCHEDULE", True, cast=bool)
COMMISSION_RATE = quorum.conf("OMNIX_COMMISSION_RATE", 0.01, cast=float)
COMMISSION_DAY = quorum.conf("OMNIX_COMMISSION_DAY", 26, cast=int)
IMAGE_RESIZE = quorum.conf("OMNIX_IMAGE_RESIZE", "crop")
LOCALE = quorum.conf("OMNIX_LOCALE", "en_us")
QUEUE = quorum.conf("OMNIX_QUEUE", "omnix")
RECORD_CHUNK = quorum.conf("OMNIX_RECORD_CHUNK", 256, cast=int)
コード例 #22
0
ファイル: httpc.py プロジェクト: hivesolutions/flask_quorum
 def setUp(self):
     quorum.TestCase.setUp(self)
     self.httpbin = quorum.conf("HTTPBIN", "httpbin.org")