Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def Store(self, obj, envKey):
"""Stores authorization token passed as an argument.
param obj instance to be stored.
"""
DefaultStorageStrategy.cache_path = os.path.join(Configuration.TempPath, "cached-data." + envKey + ".py")
if obj == None:
return
lock = fasteners.ReaderWriterLock()
with lock.write_lock():
fp = open(DefaultStorageStrategy.cache_path,'w')
os.chmod(DefaultStorageStrategy.cache_path, stat.S_IRUSR|stat.S_IWUSR)
# Write it to the result to the file as a json
serializedObj = "#" + json.dumps(obj.__dict__)
# add hash to prevent download token file via http when path is invalid
fp.write(serializedObj)
fp.close()
def billing(app_conf):
from mangopaysdk.configuration import Configuration
Configuration.BaseUrl = app_conf.mangopay_base_url
Configuration.ClientID = app_conf.mangopay_client_id
Configuration.ClientPassword = app_conf.mangopay_client_password
Configuration.SSLVerification = True
def billing(app_conf):
from mangopaysdk.configuration import Configuration
Configuration.BaseUrl = app_conf.mangopay_base_url
Configuration.ClientID = app_conf.mangopay_client_id
Configuration.ClientPassword = app_conf.mangopay_client_password
Configuration.SSLVerification = True
def __init__(self):
#########################################
# Config/authorization related fields
#########################################
# Configuration instance with default settings (to be reset if required).
self.Config = Configuration
self.OAuthTokenManager = AuthorizationTokenManager(self);
#########################################
# API managers fields
#########################################
self.authenticationManager = apioauth.ApiOAuth(self)
self.clients = apiclients.ApiClients(self)
self.users = apiusers.ApiUsers(self)
self.wallets = apiwallets.ApiWallets(self)
self.transfers = apitransfers.ApiTransfers(self)
self.payIns = apipayins.ApiPayIns(self)
self.payOuts = apipayouts.ApiPayOuts(self)
self.refunds = apirefunds.ApiRefunds(self)
self.cardRegistrations = apicardregistrations.ApiCardRegistrations(self)
self.cardPreAuthorizations = apicardpreauthorizations.ApiCardPreAuthorizations(self)
# Constant to switch debug mode (0/1) - display all request and response data
DebugMode = 0
# SSL verification (False (no verification) or path to the cacert.pem file)
SSLVerification = False
# RestTool class
# NB: you can swap this class for one of ours that implement some custom logic
RestToolClass = None
# Session object from the `requests` library
Session = None
# we use DEBUG level for internal debugging
if (Configuration.DebugMode):
logging.basicConfig(level=logging.DEBUG)
def Get(self, envKey):
"""Gets the currently stored objects as dictionary.
return stored Token dictionary or null.
"""
DefaultStorageStrategy.cache_path = os.path.join(Configuration.TempPath, "cached-data." + envKey + ".py")
if not os.path.exists(DefaultStorageStrategy.cache_path):
return None
lock = fasteners.ReaderWriterLock()
with lock.read_lock():
fp = open(DefaultStorageStrategy.cache_path,'rb')
serializedObj = fp.read().decode('UTF-8')
try:
cached = json.loads(serializedObj[1:])
except:
cached = None
fp.close()
return OAuthToken(cached)