Example #1
0
async def return_spare(walletID, depositAddress):
    balanceraw = await get_balance(depositAddress)
    balanceint = int(balanceraw) / 10**29
    if balanceint == 0:
        return None
    else:
        print("\nThe temporary deposit address still has " + str(balanceint) +
              "ban remaining!")
        while Validations.get_banano_address(returnAddr) is not None:
            returnAddr = input(
                "Enter the banano address you would like to return the spare to \n"
            )
            returnAddr = Validations.get_banano_address(returnAddr)
            if Validations.validate_address(returnAddr) is True:
                print("Sending remaining bans to: " + returnAddr)
                break
            else:
                print(returnAddr + " is not a valid account")
        try:
            await send_payment(walletID, depositAddress, returnAddr,
                               balanceraw)
        except Exception as e:
            print(e)
            print(
                "Publishing block failed. Funds remain in distribution address\n"
            )
Example #2
0
File: Person.py Project: gomri/bank
    def __init__(self, name, age, email, wallet=0, person_type=None):
        """

        Validations() a class the validates password and username and sets them
        :param name:
        :param age:
        :param username:
        :param email:
        :param password:
        :param wallet:
        :param salary:
        :param job:
        :param person_type:
        """
        validation = Validations()
        self.person_type = person_type
        self.name = name
        self.age = age
        self.email = email
        self.username = validation.username_check()
        self.password = validation.password_check()
        self.wallet = wallet
        self.logged_in = None
        self.saving_account = None
        self.checkings_account = None
Example #3
0
async def load_addresses():
    filename = input("Enter the csv payment list here: \n")
    try:
        data = pd.read_csv(filename)
        addresses = list(data["addresses"])
        valid_addresses = set()

        for address in addresses:
            if Validations.get_banano_address(address) is not None:
                valid_addresses.add(Validations.get_banano_address(address))
        print("Total addresses: " + str(len(valid_addresses)))
        try:
            f = open("paid.txt", "r")
        except:
            open("paid.txt", "x")
            f = open("paid.txt", "r")
        previous = set(f.read().splitlines())
        unpaid = valid_addresses.difference(previous)
        print(len(unpaid), "unpaid:")
        print(unpaid)
        input("Press enter to continue")
        return unpaid
    except Exception as e:
        print(e)

    valid_addresses = set()
    return valid_addresses
 def addBook(self):
     """
         Use the entered information if it is valid in order to add the
         book after the Add button is pushed.
     """
     data = [
         self.titleEdit.text(),
         self.authorEdit.text(),
         self.yearEdit.text(),
         self.genre_options.currentText(),
         self.ratingEdit.text(),
         self.copiesEdit.text(),
     ]
     invalid_data = Validations.check_all(*data)
     if invalid_data == []:
         new_book = Book(*data)
         Library.add_book(new_book)
         self.label.setText("You added the book successfully!")
     else:
         message = "Unsuccessful addition!Invalid:\n"
         message += "\n".join(invalid_data)
         self.label.setText(message)
     for gadget in self.gadgets:
         if gadget != self.genre_options:
             gadget.clear()
Example #5
0
async def main():
    filename = input("Enter the csv payment list here: \n")
    data = pd.read_csv(filename)
    amounts = list(data["amount"])
    total = 0
    for amount in amounts:
        total = total + amount
    print("Total: " + str(total))
    print(data)

    walletID = await get_wallet()
    paymentadd = await account_create(walletID)

    while not await enough_bans(paymentadd, total):
        input("Please ensure " + str(paymentadd) + " has enough bans to pay " + str(total) + "banano\n")

    f = open("paid.txt", "a+")
    for index, row in data.iterrows():
        print(row[0]) # address
        if Validations.get_banano_address(row[0]) is not None:
            print("IT'S AN ADDRESS")
            print("Sending " + str(row[1]) + "ban to " + row[0] + " - " + str(index+1) + "/" + str(len(data)))
            block = await send_payment(walletID, paymentadd, row[0], row[1])
            f.write(row[0] + " - " + str(row[1]) + "\n Block: " + block + "\n")

        else:
            print("nonvalid")
    f.close()


    await destroy_wallet(walletID)
Example #6
0
class Test(unittest.TestCase):
    def setUp(self):
        self.ship = 'A1A2A3'
        self.invalid_ship = 'A0A1A2'
        self.validations = Validations()

    def tearDown(self):
        pass

    def testShipValidation(self):
        self.validations.ship_validation(self.ship)
        try:
            self.validations.ship_validation(self.invalid_ship)
            assert (False)
        except ValidationError as error:
            self.assertEqual(str(error), 'Point not on board!')
    def removeBook(self):
        """
            Use the entered information if it is valid in order to remove the
            book after the Add button is pushed.
        """
        data = [self.titleEdit.text(), self.authorEdit.text(), self.yearEdit.text(), self.genre_options.currentText()]

        invalid_data = Validations.check_all(*data)
        if invalid_data == []:
            book = Book(
                self.titleEdit.text(),
                self.authorEdit.text(),
                self.yearEdit.text(),
                self.genre_options.currentText(),
                0,
                0,
            )
            Library.remove_book(book)
            self.label.setText("You removed the book successfully!")
        else:
            message = "Unsuccessful removal!Invalid:\n"
            message += "\n".join(invalid_data)
            self.label.setText(message)
        for edit in (self.titleEdit, self.authorEdit, self.yearEdit):
            edit.clear()
Example #8
0
    def get(self, cpf):

        if not validations.isValidCpf(cpf):
            return {
                'code': '1001',
                "message": 'Invalid CPF'
            }, status.HTTP_412_PRECONDITION_FAILED

        user = db.getUserInfo(cpf)

        return json.dumps(user.__dict__)
Example #9
0
async def send_funds(walletID, source):
    valid_addresses = []
    async with aiofiles.open("addresses.txt") as file:
        async for line in file:
            if Validations.get_banano_address(line) is not None:
                account = Validations.get_banano_address(line)
                if Validations.validate_address(account) is True:
                    valid_addresses.append(account)
                else:
                    print(account + " is not a valid account")
            else:
                print(account + " does not fit the form of an address")
    num_addresses = len(valid_addresses)
    sourcebal = await get_balance(source)
    sourcebal = int(sourcebal) / 10**29
    remainder = sourcebal % num_addresses
    banperacc = (sourcebal - remainder) / num_addresses
    print("Sending " + str(banperacc) + "ban to " + str(num_addresses) +
          " accounts!")
    for account in valid_addresses:
        account = account.strip()
        print("Sending " + str(banperacc) + "ban to " + account)
        await send_payment(walletID, source, account,
                           str(int(banperacc) * 10**29))
Example #10
0
def get_last_login_day(mobile_number):
    con = DBConnectivity.create_connection()
    db_cursor = DBConnectivity.create_cursor(con)
    try:
        if Validations.is_user_present(mobile_number):
            sql_statement = "select case when to_char(last_login ,'yyyy-mm-dd')=to_char(systimestamp,'yyyy-mm-dd') then 'today' when to_char(last_login ,'yyyy-mm-dd')=to_char(systimestamp-1,'yyyy-mm-dd') then 'yesterday' else to_char(last_login,'Dy, dd Mon') end from login where mob_no=" + str(
                mobile_number)
            db_cursor.execute(sql_statement)
        for row in db_cursor:
            return row[0]
    except CustomExceptions.MobileNumberNotPresent as e:
        print(e)
    finally:
        db_cursor.close()
        con.close()
Example #11
0
def get_password(mobile_number):
    con = DBConnectivity.create_connection()
    db_cursor = DBConnectivity.create_cursor(con)
    try:
        if Validations.is_user_present(mobile_number):
            sql_statement = "select pwd   from usr where MOB_NO=" + str(
                mobile_number)
            db_cursor.execute(sql_statement)
            for row in db_cursor:
                return row[0]
    except CustomExceptions.MobileNumberNotPresent as e:
        print(e)
        return None
    finally:
        db_cursor.close()
        con.close()
Example #12
0
def get_blocked_status(mobile_number):
    sql_statements = "select blocked_status from login where mob_no =" + str(
        mobile_number)
    con = DBConnectivity.create_connection()
    db_cursor = DBConnectivity.create_cursor(con)
    try:
        if Validations.is_user_present(mobile_number):

            db_cursor.execute(sql_statements)
            for row in db_cursor:
                return row[0]
    except CustomExceptions.MobileNumberNotPresent as e:
        print(e)
    finally:
        db_cursor.close()
        con.close()
Example #13
0
def get_last_login_time(mobile_number):
    con = DBConnectivity.create_connection()
    db_cursor = DBConnectivity.create_cursor(con)
    try:
        if Validations.is_user_present(mobile_number):
            sql_statement = "select last_login     from login where mob_no=" + str(
                mobile_number)
            db_cursor.execute(sql_statement)
        for row in db_cursor:
            db_cursor.close()
            con.close()
            return row[0]
    except CustomExceptions.MobileNumberNotPresent as e:
        print(e)
        db_cursor.close()
        con.close()
        return None
Example #14
0
def get_display_name(mobile_number):
    con = DBConnectivity.create_connection()
    db_cursor = DBConnectivity.create_cursor(con)
    try:
        if Validations.is_user_present(mobile_number):
            sql_statement = "select disp_name,mob_no    from login where mob_no=" + str(
                mobile_number)
            db_cursor.execute(sql_statement)
        for row in db_cursor:
            if row[0] != None:
                return row[0]
            else:
                return row[1]
    except CustomExceptions.MobileNumberNotPresent as e:
        print(e)
        return None
    finally:
        db_cursor.close()
        con.close()
Example #15
0
 def test_validCpf(self):
     self.assertTrue(validations.isValidCpf("22544050047"))
Example #16
0
 def setUp(self):
     self.ship = 'A1A2A3'
     self.invalid_ship = 'A0A1A2'
     self.validations = Validations()
Example #17
0
from validations import Validations
import json

cluster = MongoClient(
    "mongodb+srv://audiofile:[email protected]/myFirstDatabase?retryWrites=true&w=majority"
)

database = cluster["AudioFile"]

collection_audiobook = database["AudioBook"]
collection_podcast = database["Podcast"]
collection_song = database["Song"]

file = open('create_song.json')
data = json.load(file)
print(data)

schema_check = Validations.get_schema(data)

if validate(instance=data, schema=schema_check) is None:
    insertable_data = data["records"]
    if data["audio_type"] == "Song":
        collection_song.insert_many(insertable_data)
    if data["audio_type"] == "Podcast":
        collection_podcast.insert_many(insertable_data)
    if data["audio_type"] == "AudioBook":
        collection_audiobook.insert_many(insertable_data)
else:
    print("bye")
# collection_audiobook.delete_many({})
Example #18
0
 def test_invalidCpf(self):
     self.assertFalse(validations.isValidCpf("12345"))
Example #19
0
from Board import Board, Square
from Console import Console
from service import Service
from validations import Validations

user = Board('u')
computer = Board('c')

validations = Validations()
service = Service(user, computer, validations)
console = Console(service)
'''
mysquare=Square()
print(mysquare)
'''

console.run()
Example #20
0
        user=conf['DBuser'],
        password=conf['DBpwd'],
    )
    connection.autocommit = True
    return connection


if __name__ == '__main__':

    # Read arguments and configurations and initialize
    args = ccloud_lib.parse_args()
    config_file = args.config_file
    topic = args.topic
    conf = ccloud_lib.read_ccloud_config(config_file)
    db_conf = read_db_config(DBConfig)
    v = Validations()
    conn = dbconnect(db_conf)

    # Create Consumer instance
    # 'auto.offset.reset=earliest' to start reading from the beginning of the
    #   topic if no committed offsets exist
    consumer = Consumer({
        'bootstrap.servers': conf['bootstrap.servers'],
        'sasl.mechanisms': conf['sasl.mechanisms'],
        'security.protocol': conf['security.protocol'],
        'sasl.username': conf['sasl.username'],
        'sasl.password': conf['sasl.password'],
        'group.id': 'sensor_readings_consumer',
        'auto.offset.reset': 'earliest',
    })