Ejemplo n.º 1
0
 def receive(self, mail_message):
     logger = logging.getLogger()
     t = mail_message.to
     mobile = mail_message.sender
     subj = mail_message.subject
     bodies = mail_message.bodies('text/plain')
     for body in bodies:
         b = body[1].decode()
     logger.info("From: " + mobile)
     logger.info("To: " + t)
     logger.info(mail_message.date)
     logger.info("Subject: " + subj)
     logger.info("Body: " + b)
     if 'SMS' in subj:
         if 'account' in b.lower():
             reply = accounts.createAccount(mobile, b)
         else:
             reply = return_info.main(b, mail_message.date, True, mobile)
         account = accounts.getAccount(mobile)
         logger.info(reply[0])
         logger.info(reply[1])
         logger.info(account)
         if account != None:
             mail.send_mail(sender="*****@*****.**",
                            to=account,
                            subject=reply[0],
                            body=reply[1])
Ejemplo n.º 2
0
 def test_Account(self):
     resp = accounts.new(self.nodeServer, ent=128)
     print('new', resp)
     if resp['done'] == True:  # 如果返回结果为true,
         _newSecret = resp['data']['secret']  # 获取新建账号返回结果中的地址和公钥
         _newPublicKey = resp['data']['publicKey']
         _newAddress = resp['data']['address']
         print('open', accounts.open(self.nodeServer, _newSecret))
         print('open2', accounts.open2(self.nodeServer, _newPublicKey))
         print('getBalance',
               accounts.getBalance(self.nodeServer, _newAddress))
         print('getPublicKey',
               accounts.getPublicKey(self.nodeServer, _newAddress))
         print(
             'generatePublicKey',
             accounts.generatePublicKey(self.nodeServer,
                                        self.genesisSecret))
         print('getDelegates',
               accounts.getDelegates(self.nodeServer, _newAddress))
         print('getAccount',
               accounts.getAccount(self.nodeServer, _newAddress))
         print('accountOnChain',
               accounts.accountOnChain(self.nodeServer, _newAddress))
         print('delayOrders',
               accounts.delayOrders(self.nodeServer, _newAddress))
         print('delayOrders',
               accounts.delayOrders(self.nodeServer, _newAddress, 1))
Ejemplo n.º 3
0
    def receive(self, mail_message):
		logger = logging.getLogger()
		t = mail_message.to
		mobile = mail_message.sender
		subj = mail_message.subject
		bodies = mail_message.bodies('text/plain')
		for body in bodies:
			b = body[1].decode()
		logger.info("From: " + mobile)
		logger.info("To: " + t)
		logger.info(mail_message.date)
		logger.info("Subject: " + subj)
		logger.info("Body: " + b)
		if 'SMS' in subj:
			if 'account' in b.lower():
				reply = accounts.createAccount(mobile,b)
			else:
				reply = return_info.main(b,mail_message.date,True,mobile)
			account = accounts.getAccount(mobile)
			logger.info(reply[0])
			logger.info(reply[1])
			logger.info(account)
			if account != None:
				mail.send_mail(sender = "*****@*****.**",
							to = account,
							subject = reply[0],
							body =  reply[1])
Ejemplo n.º 4
0
def sendEmail(name, body):

    email = makeEmail(name, body)
    address = a.getAccount(name)

    server = s.SMTP(SMTP_URL, SMTP_PRT)
    
    server.starttls()
    server.login(i.getUsername(), i.getPassword())
    
    server.sendmail(i.getUsername(), address, email)
    server.quit()
Ejemplo n.º 5
0
def makeEmail(name, body):
    address = a.getAccount(name)

    eml = MIMEMultipart()
    eml["From"] = i.USERNAME
    eml["To"] = address
    eml["Subject"] = "The Postwoman's been..."

    eml.attach(MIMEText(body, 'plain'))

    textEml = eml.as_string()

    return textEml
Ejemplo n.º 6
0
def addCategory(args, list_categories, list_accounts, list_rates, debugEnabled, context):
    cat  = Category()
    if len(args)<CAT_SIGN_IDX+1:
        print "ERROR: Category definition: expected transaction sign (+) or (-) in %d position" % (CAT_SIGN_IDX)
        sys.exit(-1)
    sign = args[CAT_SIGN_IDX]
    if len(args)<CAT_AMOUNT_IDX+1:
        print "ERROR: Category definition: expected amount in %d position" % (CAT_AMOUNT_IDX)
        sys.exit(-1)
    if sign == '+':
        cat.debit = float(args[CAT_AMOUNT_IDX])
    else:
        cat.credit = float(args[CAT_AMOUNT_IDX])
    if len(args)<CAT_CURRENCY_IDX +1:
        print "ERROR: Category definition: expected currency name in %d position" % (CAT_CURRENCY_IDX )
        sys.exit(-1)
    cat.currency = args[CAT_CURRENCY_IDX]
    if len(args)<CAT_ACCOUNT_IDX+1:
        print "ERROR: Category definition: expected account name in %d position" % (CAT_ACCOUNT_IDX)
        sys.exit(-1)
    cat.account = args[CAT_ACCOUNT_IDX]
    if len(args)<CAT_CATEGORY_IDX+1:
        print "ERROR: Category definition: expected category in %d position" % (CAT_CATEGORY_IDX)
        sys.exit(-1)
    cat.category = args[CAT_CATEGORY_IDX]
    if len(args)>CAT_DESCRIPTION_IDX:
        cat.description = args[CAT_DESCRIPTION_IDX]
    #find account 
    if cat.account != "-":
        acc = getAccount(list_accounts, cat.account, context)
        acc.addDebitCredit(excangeCurrency(list_rates, cat.currency, cat.debit, acc.currency, context), 
                           excangeCurrency(list_rates, cat.currency, cat.credit, acc.currency, context))
    #find or creare category
    if cat.category != "-":
        if list_categories.has_key(cat.category):
            list_categories[cat.category].debit += cat.debit
            list_categories[cat.category].credit += cat.credit
            if debugEnabled: print "Updated %s" % (cat)
        else:
            list_categories[cat.category] = cat
            if debugEnabled: print "Added %s" % (cat)
    return cat
Ejemplo n.º 7
0
def AddTransactions2():
    list_account = get_account()
    url = list_account['url']
    secret = list_account['secret']
    address = list_account['address']  # 获取字典的key对应value值
    reciptionid = list_account['reciptionid']
    a = random.randint(10, 2000)
    transactions.add(nodeServer=url,
                     secret=secret,
                     recipientId=reciptionid,
                     amount=a)
    print(
        '给其他用户转账:', 'RecipientId:' + reciptionid,
        transactions.add(nodeServer=url,
                         secret=secret,
                         recipientId=reciptionid,
                         amount=a + 1))
    address = list_account['address']  # 获取字典的key对应value值
    resp = accounts.getAccount(nodeServer=url, address=address)
    print('getAccount获取新建账户信息还没有生成publickey', 'Secret:' + secret,
          'address:' + address, resp)
Ejemplo n.º 8
0
def getAccount(id):
    return jsonify(Accounts.getAccount(id))
Ejemplo n.º 9
0
if __name__ == "__main__":
    accounts.addDelegates(_nodeServer, _genesisSecret, remove='a08dc0d7b170a0e12caff0a7faaef952741e65f3585905a5847e4d877d650f07')
    resp = accounts.new(_nodeServer, ent=128)
    print('new', resp)
    if resp['done'] == True:  #如果返回结果为true,
        _newSecret = resp['data']['secret']   #获取新建账号返回结果中的地址和公钥
        _newPublicKey = resp['data']['publicKey']
        _newAddress = resp['data']['address']
        print('open', accounts.open(_nodeServer, _newSecret))
        print('open2', accounts.open2(_nodeServer, _newPublicKey))
        print('getBalance', accounts.getBalance(_nodeServer, _newAddress))
        print('getPublicKey', accounts.getPublicKey(_nodeServer, _newAddress))
        print('generatePublicKey', accounts.generatePublicKey(_nodeServer, _newSecret))
        print('getDelegates', accounts.getDelegates(_nodeServer, _newAddress))
        print('getAccount', accounts.getAccount(_nodeServer, _newAddress))
        print('accountOnChain', accounts.accountOnChain(_nodeServer, _newAddress))
        print('delayOrders', accounts.delayOrders(_nodeServer, _newAddress))
        print('delayOrders', accounts.delayOrders(_nodeServer, _newAddress, 1))

    print('===========================================')
    print('open', accounts.open(_nodeServer, _genesisSecret))
    print('open2', accounts.open(_nodeServer, _genesisPublicKey))
    print('getBalance', accounts.getBalance(_nodeServer, _genesisAddress))
    print('getPublicKey', accounts.getPublicKey(_nodeServer, _genesisAddress))
    print('generatePublicKey', accounts.generatePublicKey(_nodeServer, _genesisSecret))
    print('getDelegates', accounts.getDelegates(_nodeServer, _genesisAddress))
    print('getDelegateFee', accounts.getDelegateFee(_nodeServer))
    print('getAccount', accounts.getAccount(_nodeServer, _genesisAddress))
    print('accountOnChain', accounts.accountOnChain(_nodeServer, _genesisAddress))
    print('delayOrders', accounts.delayOrders(_nodeServer, _genesisAddress))
Ejemplo n.º 10
0
 def test_getAccount(self):
     resp = accounts.getAccount(self.nodeServer, self.genesisAddress)
     # print('getAccount', accounts.getAccount(self.nodeServer, self.genesisAddress))
     print('getAccount',
           accounts.getAccount(self.nodeServer, self.genesisAddress))