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
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)
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)
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 )
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)
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
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)
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, {})
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
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
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)
) """ 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
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)
def setUp(self): quorum.TestCase.setUp(self) self.httpbin = quorum.conf("HTTPBIN", "httpbin.org")
""" 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)