This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fmt_currency(val): | |
tmp = val | |
if not isinstance(tmp, str): | |
tmp = str(tmp) | |
if val < 100: | |
cents = tmp | |
dollars = "0" | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def addClient(self, email, cardUri): | |
try: | |
client = balanced.Marketplace.my_marketplace.create_buyer(email, cardUri) | |
return True | |
except balanced.exc.HttpError as e: | |
if e.category_code == "duplicate-email-address": | |
buyer = balanced.Account.query.filter(email_address=email) | |
print buyer | |
buyer = buyer[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try{ | |
$trans = $mp->debits->query()->filter(Balanced\Debit::$f->transaction_number->eq($_POST['id']))->one(); | |
//} catch(Balanced\Exceptions\HTTPError $e){ | |
// die(json_encode(array("error" => "No transaction found."))); | |
} catch(Balanced\Exceptions\MultipleResultsFound $e){ | |
print_r($e);die; | |
//die(json_encode(array("error" => "No transaction found."))); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> num = "100" | |
>>> print sum([int(x)*(2**int(z)) for z,x in enumerate(num[::-1])]) | |
4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def search_cc(self, cc): | |
if not isinstance(cc, str): | |
cc = str(cc) | |
if len(cc) < 4: | |
print "Invalid length for CC" | |
return False | |
try: | |
cards = list(balanced.Marketplace.query.one().cards) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def testing(self, addr): | |
cards = None | |
try: | |
buyer = balanced.Account.query.filter(email_address=addr)[0] | |
cards = list(balanced.Card.query.filter(card_uri=buyer.cards_uri)) | |
except: | |
pass | |
return cards |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
conf['system']['log_level'] = "debug,info" | |
try: | |
conf_level = conf['system']['log_level'].split(",") | |
LEVELS = { "debug" : logging.DEBUG, "info" : logging.INFO, "warning" : logging.WARNING, "error" : logging.ERROR, "critical" : logging.CRITICAL} | |
for level in conf_level: | |
self.log.setLevel(LEVELS[level]) | |
except: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ClassBase: | |
def __init__(self, log_name, client = True): | |
try: | |
self.conf | |
except: | |
self.conf = Config() | |
try: | |
self.log | |
except: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def head(self, options): | |
try: | |
if options['method'] is not "": | |
url = "%s/%s" % (options['url'], options['method']) | |
else: | |
url = "%s" % (options['url']) | |
except: | |
raise APIException("No API method call provided.") | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class APIBase(ClassBase): | |
# Both SL and SVB require authentication tokens. So we set a field here for them | |
tokens = {'sl' : "", 'svb' : ""} | |
# Enable support for proxies | |
proxy = {"https" : ""} | |
def __init__(self, class_name = "api.base"): | |
ClassBase.__init__(self, class_name) | |
OlderNewer