Esempio n. 1
0
 def run(self, code):
     mlog.debug("Running code:\n\n", code)
     if self.is_cross and self.exe_wrapper is None:
         raise CrossNoRunException("Can not run test applications in this cross environment.")
     (fd, srcname) = tempfile.mkstemp(suffix="." + self.default_suffix)
     os.close(fd)
     ofile = open(srcname, "w")
     ofile.write(code)
     ofile.close()
     exename = srcname + ".exe"  # Is guaranteed to be executable on every platform.
     commands = self.get_exelist()
     commands.append(srcname)
     commands += self.get_output_args(exename)
     p = subprocess.Popen(commands, cwd=os.path.split(srcname)[0], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (stdo, stde) = p.communicate()
     stde = stde.decode()
     stdo = stdo.decode()
     mlog.debug("Compiler stdout:\n", stdo)
     mlog.debug("Compiler stderr:\n", stde)
     os.remove(srcname)
     if p.returncode != 0:
         return RunResult(False)
     if self.is_cross:
         cmdlist = self.exe_wrapper + [exename]
     else:
         cmdlist = exename
     pe = subprocess.Popen(cmdlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (so, se) = pe.communicate()
     so = so.decode()
     se = se.decode()
     mlog.debug("Program stdout:\n", so)
     mlog.debug("Program stderr:\n", se)
     os.remove(exename)
     return RunResult(True, pe.returncode, so, se)
Esempio n. 2
0
    def validate_login_key(self, login_key, min_len=5, max_len=8):
        self.result = False
        self.message = ""
        self.min_len = min_len
        self.max_len = max_len
        mlog.debug(
            self.TAG, "Validating : " + str(login_key) + "(" +
            str(self.min_len) + "-" + str(self.max_len) + ")")
        regex_login_key = re.compile("[a-zA-Z0-9]+")
        if login_key == None:
            self.message = "<P>Password can not be empty!</p>"
        elif len(str(login_key)) < self.min_len or len(
                str(login_key)) > self.max_len:
            self.message = "<p>Password must be at least " + str(
                self.min_len) + " characters and  max " + str(
                    self.max_len) + "</p>"
        elif regex_login_key.match(login_key) is None:
            self.message = "<p>Password can be only alphanumeric, may or may not contain digits.</p>"
        else:
            match = regex_login_key.match(login_key)
            #print(match.group(0))
            if login_key == match.group(0):
                self.result = True
                self.message = "<p>Valid password!</p>"
            else:
                self.message = "<p>Password should be only alphanumeric, must start with alphabet and may contain digits.</p>"

        return self.result
Esempio n. 3
0
 def debit(self, amount):
     mlog.debug(self.TAG, "debit(" + str(amount) + ")")
     if self.can_debit(amount):
         self.balance -= int(amount)
         return True
     else:
         return False
Esempio n. 4
0
    def insert_to_account(self):
        try:
            conn = mysql.connector.connect(**config)
            cursor = conn.cursor()
        except Exception as e:
            mlog.error(TAG,"Unable to conenct to MyBanking Database.")
            print('''
        <h4>Unable to conenct to MyBanking Database.</h4>
            <div id="entry" >
                <a href="show_register.py">BACK</a>
            </div>
        ''')
            print(helperHTML.get_html_end_preset())
            sys.exit()

        insert_account = "INSERT INTO ACCOUNT(ACC_NUMBER, NAME, BANK_NAME, BRANCH_NAME, IFSC_CODE, BALANCE) "
        insert_account += "VALUES (" + str(self.acc_number) + ", '" + str(self.name) + "' , '" + str(self.bank_name) + "' , '" + str(self.branch_name) + "' ,"
        insert_account += "'" + str(self.ifsc_code) + "' , "+ str(self.__balance_amt) + ");"
        mlog.debug(TAG, insert_account)
        insert_status = False
        error = None
        try:
            cursor.execute(insert_account)
            conn.commit()
        except Exception as e:
            error = str(e)
            mlog.error(TAG,"Error: " + error)
            insert_status = True

        cursor.close()
        conn.close()

        return insert_status, error
Esempio n. 5
0
    def validate_bank_name(self, bank_name, min_len=3, max_len=15):
        self.result = False
        self.message = ""
        self.min_len = min_len
        self.max_len = max_len
        mlog.debug(
            self.TAG, "Validating : " + str(bank_name) + "(" +
            str(self.min_len) + "-" + str(self.max_len) + ")")
        regex_bank_name = re.compile("[a-zA-Z]+[ ]{0,1}[a-zA-Z]+")
        if bank_name == None:
            self.message = "<P>Bank name can not be empty!</p>"
        elif len(str(bank_name)) < self.min_len or len(
                str(bank_name)) > self.max_len:
            self.message = "<p>Bank name must be at least " + str(
                self.min_len) + " characters and  max " + str(
                    self.max_len) + "</p>"
        elif regex_bank_name.match(bank_name) is None:
            self.message = "<p>Bank name must be alphabetic. May contain one space in between.</p>"
        else:
            match = regex_bank_name.match(bank_name)
            #print(match.group(0))
            if bank_name == match.group(0):
                self.result = True
                self.message = "<p>Valid bank name!</p>"
            else:
                self.message = "<p>Bank name must be alphabetic. May contain one space in between.</p>"

        return self.result
Esempio n. 6
0
 def validate_generic_name(self, generic_name, min_len=5, max_len=8):
     self.result = False
     self.message = ""
     self.min_len = min_len
     self.max_len = max_len
     mlog.debug(
         self.TAG, "Validating : " + str(generic_name) + "(" +
         str(self.min_len) + "-" + str(self.max_len) + ")")
     regex_generic_name = re.compile("[a-zA-Z]+[a-zA-Z0-9]*")
     if generic_name == None:
         self.message = "<P>User name can not be empty!</p>"
     elif len(str(generic_name)) < self.min_len or len(
             str(generic_name)) > self.max_len:
         self.message = "<p>User name must be at least " + str(
             self.min_len) + " characters and  max " + str(
                 self.max_len) + "</p>"
     elif regex_generic_name.match(generic_name) is None:
         self.message = "<p>User name should be only alphabetic.</p>"
     else:
         match = regex_generic_name.match(generic_name)
         if generic_name == match.group(0):
             self.result = True
             self.message = "<p>Valid User name!</p>"
         else:
             self.message = "<p>User name should be only alphabetic(Only first and last names are accepted).</p>"
     return self.result
Esempio n. 7
0
 def validate_login_name(self, login_name, min_len=5, max_len=8):
     self.result = False
     self.message = ""
     self.min_len = min_len
     self.max_len = max_len
     mlog.debug(
         self.TAG, "Validating : " + str(login_name) + "(" +
         str(self.min_len) + "-" + str(self.max_len) + ")")
     regex_login_name = re.compile("[a-zA-Z][a-zA-Z0-9]*")
     if login_name == None:
         self.message = "<P>Login name can not be empty!</p>"
     elif len(str(login_name)) < self.min_len or len(
             str(login_name)) > self.max_len:
         self.message = "<p>Login name must be at least " + str(
             self.min_len) + " characters and  max " + str(
                 self.max_len) + "</p>"
     elif regex_login_name.match(login_name) is None:
         self.message = "<p>Login name should be only alphanumeric, must start with alphabet and may or may not contain digits.</p>"
     else:
         match = regex_login_name.match(login_name)
         if login_name == match.group(0):
             self.result = True
             self.message = "<p>Valid login name!</p>"
         else:
             self.message = "<p>Login name should be only alphanumeric, must start with alphabet and may contain digits.</p>"
     return self.result
Esempio n. 8
0
 def get_account_details(self, account_number):
     mlog.debug(TAG, "get_account_details(" + str(account_number) + ")")
     self.transaction_success = False
     self.transaction_message = ""
     all_recs = None
     try:
         query_account = "SELECT name, number, ifsc_code, bank_name, branch_name, balance FROM account WHERE number=" + str(
             account_number) + ";"
         self.db_connection.query(query_account)
         all_recs = conn.store_result()
     except Exception as e:
         self.transaction_message = str(e)
         mlog.error(TAG, "Error: " + str(e))
     obj_account = None
     if all_recs != None and all_recs.num_rows() > 0:
         row = all_recs.fetch_row()
         for item in row:
             obj_account = Account()
             obj_account.set(acc_number=int(str(item[1])),
                             acc_name=str(item[0], 'utf-8'),
                             bank=str(item[3], 'utf-8'),
                             branch=str(item[4], 'utf-8'),
                             ifsc=str(item[2], 'utf-8'),
                             balance_amt=int(str(item[5])))
             self.transaction_success = True
             self.transaction_message = "Successfully fetched account details"
     else:
         self.transaction_success = False
         self.transaction_message = "Unable to fetch account details.."
     return obj_account
Esempio n. 9
0
    def insert_to_user(self):
        try:
            conn = mysql.connector.connect(**config)
            cursor = conn.cursor()
        except Exception as e:
            mlog.error(TAG,"Unable to conenct to MyBanking Database.")
            print('''
        <h4>Unable to conenct to MyBanking Database.</h4>
            <div id="entry" >
                <a href="show_register.py">BACK</a>
            </div>
        ''')
            print(helperHTML.get_html_end_preset())
            sys.exit()

        insert_user = "******" + str(self.acc_number)
        insert_user += ", '" + str(self.login_name) + "' , '" + str(self.login_key) + "' );"
        mlog.debug(TAG, insert_user)
        insert_status = False
        error = None
        try:
            cursor.execute(insert_user)
            conn.commit()
        except Exception as e:
            error = str(e)
            mlog.error(TAG,"Error: " + error)
            insert_status = True

        cursor.close()
        conn.close()

        return insert_status, error
Esempio n. 10
0
    def get_variable(self, variable_name):
        p = subprocess.Popen(
            [self.pkgbin, "--variable=%s" % variable_name, self.name], stdout=subprocess.PIPE, stderr=subprocess.PIPE
        )
        out = p.communicate()[0]
        if p.returncode != 0:
            if self.required:
                raise DependencyException("%s dependency %s not found." % (self.type_string, self.name))
        else:
            variable = out.decode().strip()
        mlog.debug("return of subprocess : %s" % variable)

        return variable
Esempio n. 11
0
    def get_variable(self, variable_name):
        p = subprocess.Popen(
            [self.pkgbin,
             '--variable=%s' % variable_name, self.name],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE)
        out = p.communicate()[0]
        if p.returncode != 0:
            if self.required:
                raise DependencyException('%s dependency %s not found.' %
                                          (self.type_string, self.name))
        else:
            variable = out.decode().strip()
        mlog.debug('return of subprocess : %s' % variable)

        return variable
Esempio n. 12
0
 def register_new_account(self, account_obj):
     mlog.debug(TAG, "register_new_account()")
     self.transaction_success = False
     self.transaction_message = ""
     try:
         sql_insert = "INSERT INTO account(number,name,ifsc_code,bank_name,branch_name,balance)"
         sql_insert += " VALUES(" + str(
             account_obj.number
         ) + ", '" + account_obj.name + "', '" + account_obj.ifsc_code + "', '" + account_obj.bank_name + "', '" + account_obj.branch_name + "'," + str(
             account_obj.balance) + ")"
         self.db_connection.query(sql_insert)
         self.transaction_success = True
         self.transaction_message = "Successfully registered new user!"
     except Exception as e:
         self.transaction_message = str(e)
         mlog.error(TAG, "Error: " + error_message)
     return self.transaction_success
Esempio n. 13
0
 def update_account_details(self, account_obj):
     mlog.debug(TAG, "set_account_details(" + str(account_obj.number) + ")")
     self.transaction_success = False
     self.transaction_message = ""
     all_recs = None
     try:
         query_update = "UPDATE account SET name='" + str(
             account_obj.name) + "', ifsc_code='" + str(
                 account_obj.ifsc_code) + "', bank_name='" + str(
                     account_obj.bank_name) + "', branch_name='" + str(
                         account_obj.branch_name) + "', balance=" + str(
                             account_obj.balance) + " WHERE number=" + str(
                                 account_obj.number) + ";"
         self.db_connection.query(query_update)
         self.transaction_success = True
         self.transaction_message = "Successfully updated account details in DB."
     except Exception as e:
         self.transaction_message = str(e)
         mlog.error(TAG, "Error: " + str(e))
     return self.transaction_success
Esempio n. 14
0
 def initialize(self):
     mlog.debug(TAG, "initialize()")
     transaction_success = False
     transaction_message = ""
     try:
         mlog.debug(TAG, "Establishing database connection..")
         self.db_connection = _mysql.connect(db_config.db_host,
                                             db_config.db_user,
                                             db_config.db_password,
                                             db_config.db_name)
         transaction_success = True
     except Exception as e:
         mlog.error(TAG, "Unable to conenct to MyBanking Database.")
         transaction_message = '''
             <h4>Unable to conenct to MyBanking Database.</h4>
             <div id="entry" >
                 <a href="show_dashboard.py">BACK</a>
             </div>
         '''
     return transaction_success
Esempio n. 15
0
    def validate_ifsc_code(self, ifsc_code):
        self.result = False
        self.message = ""
        mlog.debug(self.TAG,"Validating : " + str(ifsc_code) +". Length must be 10 characters.")
        regex_ifsc_code = re.compile("[a-zA-Z]{4}[0-9]{6}")
        if ifsc_code == None:
            self.message = "<P>IFSC code can not be empty!</p>"
        elif len(str(ifsc_code)) != 10:
            self.message = "<p>IFSC code must be 10 characters</p>"
        elif regex_ifsc_code.match(ifsc_code) is None:
            self.message = "<p>IFSC code must be alphanumeric and in pattern: XXXXDDDDDD where X- alphabet and D-Digit.</p>"
        else:
            match = regex_ifsc_code.match(ifsc_code)
            #print(match.group(0))
            if ifsc_code == match.group(0):
                self.result = True
                self.message = "<p>Valid IFSC code!</p>"
            else:
                self.message = "<p>IFSC code must be alphanumeric and in pattern: XXXXDDDDDD where X- alphabet and D-Digit.</p>"

        return self.result
Esempio n. 16
0
    def sanity_check(self, work_dir):
        mlog.debug('Sanity testing C compiler:', ' '.join(self.exelist))
        mlog.debug('Is cross compiler: %s.' % str(self.is_cross))

        source_name = os.path.join(work_dir, 'sanitycheckc.c')
        if self.is_cross:
            binname = 'sanitycheckc_cross'
        else:
            binname = 'sanitycheckc'
        binary_name = os.path.join(work_dir, binname)
        ofile = open(source_name, 'w')
        ofile.write('int main(int argc, char **argv) { int class=0; return class; }\n')
        ofile.close()
        pc = subprocess.Popen(self.exelist + [source_name, '-o', binary_name])
        pc.wait()
        if pc.returncode != 0:
            raise EnvironmentException('Compiler %s can not compile programs.' % self.name_string())
        if self.is_cross:
            if self.exe_wrapper is None:
                # Can't check if the binaries run so we have to assume they do
                return
            cmdlist = self.exe_wrapper + [binary_name]
        else:
            cmdlist = [binary_name]
        mlog.debug('Running test binary command: ' + ' '.join(cmdlist))
        pe = subprocess.Popen(cmdlist)
        pe.wait()
        if pe.returncode != 0:
            raise EnvironmentException('Executables created by C compiler %s are not runnable.' % self.name_string())
Esempio n. 17
0
 def __init__(self, environment, kwargs):
     Dependency.__init__(self)
     self.name = 'boost'
     self.libdir = ''
     try:
         self.boost_root = os.environ['BOOST_ROOT']
         if not os.path.isabs(self.boost_root):
             raise DependencyException(
                 'BOOST_ROOT must be an absolute path.')
     except KeyError:
         self.boost_root = None
     if self.boost_root is None:
         if mesonlib.is_windows():
             self.boost_root = self.detect_win_root()
             self.incdir = self.boost_root
         else:
             self.incdir = '/usr/include'
     else:
         self.incdir = os.path.join(self.boost_root, 'include')
     self.boost_inc_subdir = os.path.join(self.incdir, 'boost')
     mlog.debug('Boost library root dir is', self.boost_root)
     self.src_modules = {}
     self.lib_modules = {}
     self.lib_modules_mt = {}
     self.detect_version()
     self.requested_modules = self.get_requested(kwargs)
     module_str = ', '.join(self.requested_modules)
     if self.version is not None:
         self.detect_src_modules()
         self.detect_lib_modules()
         self.validate_requested()
         if self.boost_root is not None:
             info = self.version + ', ' + self.boost_root
         else:
             info = self.version
         mlog.log('Dependency Boost (%s) found:' % module_str,
                  mlog.green('YES'), '(' + info + ')')
     else:
         mlog.log("Dependency Boost (%s) found:" % module_str,
                  mlog.red('NO'))
Esempio n. 18
0
 def compiles(self, code):
     mlog.debug("Running compile test:\n\n", code)
     suflen = len(self.default_suffix)
     (fd, srcname) = tempfile.mkstemp(suffix="." + self.default_suffix)
     os.close(fd)
     ofile = open(srcname, "w")
     ofile.write(code)
     ofile.close()
     commands = self.get_exelist()
     commands += self.get_compile_only_args()
     commands.append(srcname)
     p = subprocess.Popen(commands, cwd=os.path.split(srcname)[0], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     (stde, stdo) = p.communicate()
     stde = stde.decode()
     stdo = stdo.decode()
     mlog.debug("Compiler stdout:\n", stdo)
     mlog.debug("Compiler stderr:\n", stde)
     os.remove(srcname)
     try:
         trial = srcname[:-suflen] + "o"
         os.remove(trial)
     except FileNotFoundError:
         pass
     try:
         os.remove(srcname[:-suflen] + "obj")
     except FileNotFoundError:
         pass
     return p.returncode == 0
Esempio n. 19
0
 def __init__(self, environment, kwargs):
     Dependency.__init__(self)
     self.name = 'boost'
     self.libdir = ''
     try:
         self.boost_root = os.environ['BOOST_ROOT']
         if not os.path.isabs(self.boost_root):
             raise DependencyException('BOOST_ROOT must be an absolute path.')
     except KeyError:
         self.boost_root = None
     if self.boost_root is None:
         if mesonlib.is_windows():
             self.boost_root = self.detect_win_root()
             self.incdir = self.boost_root
         else:
             self.incdir = '/usr/include'
     else:
         self.incdir = os.path.join(self.boost_root, 'include')
     self.boost_inc_subdir = os.path.join(self.incdir, 'boost')
     mlog.debug('Boost library root dir is', self.boost_root)
     self.src_modules = {}
     self.lib_modules = {}
     self.lib_modules_mt = {}
     self.detect_version()
     self.requested_modules = self.get_requested(kwargs)
     module_str = ', '.join(self.requested_modules)
     if self.version is not None:
         self.detect_src_modules()
         self.detect_lib_modules()
         self.validate_requested()
         if self.boost_root is not None:
             info = self.version + ', ' + self.boost_root
         else:
             info = self.version
         mlog.log('Dependency Boost (%s) found:' % module_str, mlog.green('YES'),
                  '(' + info + ')')
     else:
         mlog.log("Dependency Boost (%s) found:" % module_str, mlog.red('NO'))
Esempio n. 20
0
    def generate(self):
        env = environment.Environment(self.source_dir, self.build_dir,
                                      self.meson_script_file, self.options)
        mlog.initialize(env.get_log_dir())
        mlog.debug('Build started at', datetime.datetime.now().isoformat())
        mlog.debug('Python binary:', sys.executable)
        mlog.debug('Python system:', platform.system())
        mlog.log(mlog.bold('The Meson build system'))
        mlog.log('Version:', coredata.version)
        mlog.log('Source dir:', mlog.bold(self.source_dir))
        mlog.log('Build dir:', mlog.bold(self.build_dir))
        if env.is_cross_build():
            mlog.log('Build type:', mlog.bold('cross build'))
        else:
            mlog.log('Build type:', mlog.bold('native build'))
        b = build.Build(env)
        if self.options.backend == 'ninja':
            import ninjabackend
            g = ninjabackend.NinjaBackend(b)
        elif self.options.backend == 'vs2010':
            import vs2010backend
            g = vs2010backend.Vs2010Backend(b)
        elif self.options.backend == 'xcode':
            import xcodebackend
            g = xcodebackend.XCodeBackend(b)
        else:
            raise RuntimeError('Unknown backend "%s".' % self.options.backend)

        intr = interpreter.Interpreter(b, g)
        if env.is_cross_build():
            mlog.log(
                'Host machine cpu family:',
                mlog.bold(intr.builtin['host_machine'].cpu_family_method([],
                                                                         {})))
            mlog.log(
                'Host machine cpu:',
                mlog.bold(intr.builtin['host_machine'].cpu_method([], {})))
            mlog.log(
                'Target machine cpu family:',
                mlog.bold(intr.builtin['target_machine'].cpu_family_method(
                    [], {})))
            mlog.log(
                'Target machine cpu:',
                mlog.bold(intr.builtin['target_machine'].cpu_method([], {})))
        mlog.log(
            'Build machine cpu family:',
            mlog.bold(intr.builtin['build_machine'].cpu_family_method([], {})))
        mlog.log('Build machine cpu:',
                 mlog.bold(intr.builtin['build_machine'].cpu_method([], {})))
        intr.run()
        g.generate(intr)
        env.generating_finished()
        dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat')
        pickle.dump(b, open(dumpfile, 'wb'))
Esempio n. 21
0
    def generate(self):
        env = environment.Environment(self.source_dir, self.build_dir, self.meson_script_file, self.options)
        mlog.initialize(env.get_log_dir())
        mlog.debug('Build started at', datetime.datetime.now().isoformat())
        mlog.debug('Python binary:', sys.executable)
        mlog.debug('Python system:', platform.system())
        mlog.log(mlog.bold('The Meson build system'))
        mlog.log('Version:', coredata.version)
        mlog.log('Source dir:', mlog.bold(self.source_dir))
        mlog.log('Build dir:', mlog.bold(self.build_dir))
        if env.is_cross_build():
            mlog.log('Build type:', mlog.bold('cross build'))
        else:
            mlog.log('Build type:', mlog.bold('native build'))
        b = build.Build(env)
        if self.options.backend == 'ninja':
            import ninjabackend
            g = ninjabackend.NinjaBackend(b)
        elif self.options.backend == 'vs2010':
            import vs2010backend
            g = vs2010backend.Vs2010Backend(b)
        elif self.options.backend == 'xcode':
            import xcodebackend
            g = xcodebackend.XCodeBackend(b)
        else:
            raise RuntimeError('Unknown backend "%s".' % self.options.backend)

        intr = interpreter.Interpreter(b, g)
        if env.is_cross_build():
            mlog.log('Host machine cpu family:', mlog.bold(intr.builtin['host_machine'].cpu_family_method([], {})))
            mlog.log('Host machine cpu:', mlog.bold(intr.builtin['host_machine'].cpu_method([], {})))
            mlog.log('Target machine cpu family:', mlog.bold(intr.builtin['target_machine'].cpu_family_method([], {})))
            mlog.log('Target machine cpu:', mlog.bold(intr.builtin['target_machine'].cpu_method([], {})))
        mlog.log('Build machine cpu family:', mlog.bold(intr.builtin['build_machine'].cpu_family_method([], {})))
        mlog.log('Build machine cpu:', mlog.bold(intr.builtin['build_machine'].cpu_method([], {})))
        intr.run()
        g.generate(intr)
        env.generating_finished()
        dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat')
        pickle.dump(b, open(dumpfile, 'wb'))
Esempio n. 22
0
#!"C:/Python34/python.exe"

import cgi, cgitb
import sys
import helperHTML
import helperSession
import mlog

TAG = "SHOW_MONEY_TRANSER"
mlog.debug(TAG, "At show_money_transfer!")
cgitb.enable()
print(helperHTML.get_html_init())
print(helperHTML.get_html_start_preset())

if (helperSession.any_session_active() == False):
    #Show session inactive..
    mlog.debug(
        TAG,
        "In show_money_transfer with no active session. So prompting to sign in again.."
    )
    print(helperHTML.get_html_invalid_session_preset())
    print(helperHTML.get_html_end_preset())
    sys.exit()

#Dump menu and show form to transfer money..
content = '''
        <div id="entry" >
            <a id="dashboard_menu_a" href="show_dashboard.py">Dashboard</a>
            <a id="dashboard_menu_a" href="show_add_payee.py">Add Payee</a>
            <a id="dashboard_menu_a" href="show_remove_payee.py">Remove Payee</a>
            <a id="dashboard_menu_a" href="show_deposit_money.py">Deposit Money</a>
Esempio n. 23
0
    def gen_vcxproj(self, target, ofname, guid, compiler):
        mlog.debug('Generating vcxproj %s.' % target.name)
        entrypoint = 'WinMainCRTStartup'
        subsystem = 'Windows'
        if isinstance(target, build.Executable):
            conftype = 'Application'
            if not target.gui_app:
                subsystem = 'Console'
                entrypoint = 'mainCRTStartup'
        elif isinstance(target, build.StaticLibrary):
            conftype = 'StaticLibrary'
        elif isinstance(target, build.SharedLibrary):
            conftype = 'DynamicLibrary'
            entrypoint = '_DllMainCrtStartup'
        elif isinstance(target, build.CustomTarget):
            return self.gen_custom_target_vcxproj(target, ofname, guid)
        elif isinstance(target, build.RunTarget):
            return self.gen_run_target_vcxproj(target, ofname, guid)
        else:
            raise MesonException('Unknown target type for %s' %
                                 target.get_basename())
        down = self.target_to_build_root(target)
        proj_to_src_root = os.path.join(down, self.build_to_src)
        proj_to_src_dir = os.path.join(proj_to_src_root, target.subdir)
        (sources, headers) = self.split_sources(target.sources)
        buildtype = self.buildtype
        project_name = target.name
        target_name = target.name
        root = ET.Element(
            'Project', {
                'DefaultTargets': "Build",
                'ToolsVersion': '4.0',
                'xmlns': 'http://schemas.microsoft.com/developer/msbuild/2003'
            })
        confitems = ET.SubElement(root, 'ItemGroup',
                                  {'Label': 'ProjectConfigurations'})
        prjconf = ET.SubElement(
            confitems, 'ProjectConfiguration',
            {'Include': self.buildtype + '|' + self.platform})
        p = ET.SubElement(prjconf, 'Configuration')
        p.text = buildtype
        pl = ET.SubElement(prjconf, 'Platform')
        pl.text = self.platform
        globalgroup = ET.SubElement(root, 'PropertyGroup', Label='Globals')
        guidelem = ET.SubElement(globalgroup, 'ProjectGuid')
        guidelem.text = guid
        kw = ET.SubElement(globalgroup, 'Keyword')
        kw.text = self.platform + 'Proj'
        ns = ET.SubElement(globalgroup, 'RootNamespace')
        ns.text = target_name
        p = ET.SubElement(globalgroup, 'Platform')
        p.text = self.platform
        pname = ET.SubElement(globalgroup, 'ProjectName')
        pname.text = project_name
        ET.SubElement(root,
                      'Import',
                      Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props')
        type_config = ET.SubElement(root,
                                    'PropertyGroup',
                                    Label='Configuration')
        ET.SubElement(type_config, 'ConfigurationType').text = conftype
        ET.SubElement(type_config, 'CharacterSet').text = 'MultiByte'
        ET.SubElement(type_config, 'WholeProgramOptimization').text = 'false'
        ET.SubElement(type_config, 'UseDebugLibraries').text = 'true'
        ET.SubElement(root,
                      'Import',
                      Project='$(VCTargetsPath)\Microsoft.Cpp.props')
        generated_files = self.generate_custom_generator_commands(target, root)
        (gen_src, gen_hdrs) = self.split_sources(generated_files)
        direlem = ET.SubElement(root, 'PropertyGroup')
        fver = ET.SubElement(direlem, '_ProjectFileVersion')
        fver.text = self.project_file_version
        outdir = ET.SubElement(direlem, 'OutDir')
        outdir.text = '.\\'
        intdir = ET.SubElement(direlem, 'IntDir')
        intdir.text = os.path.join(self.get_target_dir(target),
                                   target.get_basename() + '.dir') + '\\'
        tname = ET.SubElement(direlem, 'TargetName')
        tname.text = target_name
        inclinc = ET.SubElement(direlem, 'LinkIncremental')
        inclinc.text = 'true'

        compiles = ET.SubElement(root, 'ItemDefinitionGroup')
        clconf = ET.SubElement(compiles, 'ClCompile')
        opt = ET.SubElement(clconf, 'Optimization')
        opt.text = 'disabled'
        inc_dirs = [proj_to_src_dir, self.get_target_private_dir(target)]
        cur_dir = target.subdir
        if cur_dir == '':
            cur_dir = '.'
        inc_dirs.append(cur_dir)
        extra_args = []
        # SUCKS, VS can not handle per-language type flags, so just use
        # them all.
        extra_args += compiler.get_buildtype_args(self.buildtype)
        for l in self.environment.coredata.external_args.values():
            for a in l:
                extra_args.append(a)
        for l in self.build.global_args.values():
            for a in l:
                extra_args.append(a)
        for l in target.extra_args.values():
            for a in l:
                extra_args.append(a)
        # FIXME all the internal flags of VS (optimization etc) are represented
        # by their own XML elements. In theory we should split all flags to those
        # that have an XML element and those that don't and serialise them
        # properly. This is a crapton of work for no real gain, so just dump them
        # here.
        extra_args = compiler.get_option_compile_args(
            self.environment.coredata.compiler_options)
        if len(extra_args) > 0:
            extra_args.append('%(AdditionalOptions)')
            ET.SubElement(clconf,
                          "AdditionalOptions").text = ' '.join(extra_args)
        for d in target.include_dirs:
            for i in d.incdirs:
                curdir = os.path.join(d.curdir, i)
                inc_dirs.append(self.relpath(curdir,
                                             target.subdir))  # build dir
                inc_dirs.append(os.path.join(proj_to_src_root,
                                             curdir))  # src dir
        inc_dirs.append('%(AdditionalIncludeDirectories)')
        ET.SubElement(clconf,
                      'AdditionalIncludeDirectories').text = ';'.join(inc_dirs)
        preproc = ET.SubElement(clconf, 'PreprocessorDefinitions')
        rebuild = ET.SubElement(clconf, 'MinimalRebuild')
        rebuild.text = 'true'
        rtlib = ET.SubElement(clconf, 'RuntimeLibrary')
        rtlib.text = 'MultiThreadedDebugDLL'
        funclink = ET.SubElement(clconf, 'FunctionLevelLinking')
        funclink.text = 'true'
        pch = ET.SubElement(clconf, 'PrecompiledHeader')
        warnings = ET.SubElement(clconf, 'WarningLevel')
        warnings.text = 'Level3'
        debinfo = ET.SubElement(clconf, 'DebugInformationFormat')
        debinfo.text = 'EditAndContinue'
        resourcecompile = ET.SubElement(compiles, 'ResourceCompile')
        ET.SubElement(resourcecompile, 'PreprocessorDefinitions')
        link = ET.SubElement(compiles, 'Link')
        # Put all language args here, too.
        extra_link_args = compiler.get_option_link_args(
            self.environment.coredata.compiler_options)
        extra_link_args += compiler.get_buildtype_linker_args(self.buildtype)
        for l in self.environment.coredata.external_link_args.values():
            for a in l:
                extra_link_args.append(a)
        for l in target.link_args:
            for a in l:
                extra_link_args.append(a)
        if len(extra_args) > 0:
            extra_args.append('%(AdditionalOptions)')
            ET.SubElement(link,
                          "AdditionalOptions").text = ' '.join(extra_args)

        additional_links = []
        for t in target.link_targets:
            lobj = self.build.targets[t.get_id()]
            rel_path = self.relpath(lobj.subdir, target.subdir)
            linkname = os.path.join(rel_path, lobj.get_import_filename())
            additional_links.append(linkname)
        for o in self.flatten_object_list(target, down):
            assert (isinstance(o, str))
            additional_links.append(o)
        if len(additional_links) > 0:
            additional_links.append('%(AdditionalDependencies)')
            ET.SubElement(
                link,
                'AdditionalDependencies').text = ';'.join(additional_links)
        ofile = ET.SubElement(link, 'OutputFile')
        ofile.text = '$(OutDir)%s' % target.get_filename()
        addlibdir = ET.SubElement(link, 'AdditionalLibraryDirectories')
        addlibdir.text = '%(AdditionalLibraryDirectories)'
        subsys = ET.SubElement(link, 'SubSystem')
        subsys.text = subsystem
        gendeb = ET.SubElement(link, 'GenerateDebugInformation')
        gendeb.text = 'true'
        if isinstance(target, build.SharedLibrary):
            ET.SubElement(link,
                          'ImportLibrary').text = target.get_import_filename()
        pdb = ET.SubElement(link, 'ProgramDataBaseFileName')
        pdb.text = '$(OutDir}%s.pdb' % target_name
        if isinstance(target, build.Executable):
            ET.SubElement(link, 'EntryPointSymbol').text = entrypoint
        targetmachine = ET.SubElement(link, 'TargetMachine')
        targetmachine.text = 'MachineX86'

        if len(headers) + len(gen_hdrs) > 0:
            inc_hdrs = ET.SubElement(root, 'ItemGroup')
            for h in headers:
                relpath = h.rel_to_builddir(proj_to_src_root)
                ET.SubElement(inc_hdrs, 'CLInclude', Include=relpath)
            for h in gen_hdrs:
                if isinstance(h, str):
                    relpath = h
                else:
                    relpath = h.rel_to_builddir(proj_to_src_root)
                ET.SubElement(inc_hdrs, 'CLInclude', Include=relpath)
        if len(sources) + len(gen_src) > 0:
            inc_src = ET.SubElement(root, 'ItemGroup')
            for s in sources:
                relpath = s.rel_to_builddir(proj_to_src_root)
                ET.SubElement(inc_src, 'CLCompile', Include=relpath)
            for s in gen_src:
                relpath = self.relpath(s, target.subdir)
                ET.SubElement(inc_src, 'CLCompile', Include=relpath)
        ET.SubElement(root,
                      'Import',
                      Project='$(VCTargetsPath)\Microsoft.Cpp.targets')
        # Reference the regen target.
        ig = ET.SubElement(root, 'ItemGroup')
        pref = ET.SubElement(ig,
                             'ProjectReference',
                             Include=os.path.join(
                                 self.environment.get_build_dir(),
                                 'REGEN.vcxproj'))
        ET.SubElement(pref,
                      'Project').text = self.environment.coredata.regen_guid
        tree = ET.ElementTree(root)
        tree.write(ofname, encoding='utf-8', xml_declaration=True)
        # ElementTree can not do prettyprinting so do it manually
        doc = xml.dom.minidom.parse(ofname)
        open(ofname, 'w').write(doc.toprettyxml())
        # World of horror! Python insists on not quoting quotes and
        # fixing the escaped &quot; into &amp;quot; whereas MSVS
        # requires quoted but not fixed elements. Enter horrible hack.
        txt = open(ofname, 'r').read()
        open(ofname, 'w').write(txt.replace('&amp;quot;', '&quot;'))
Esempio n. 24
0
 def __init__(self):
     mlog.debug(TAG,"Constructor()")
Esempio n. 25
0
#!"C:/Python34/python.exe"

import cgi, cgitb
import mysql.connector
import sys
import helperHTML
import helperSession
from database.db_config import config
import mlog

TAG = "DASHBOARD"
mlog.debug(TAG, "At dashboard!")
cgitb.enable()
print(helperHTML.get_html_init())
print(helperHTML.get_html_start_preset())

if (helperSession.any_session_active() == False):
    #Show session inactive..
    mlog.debug(
        TAG,
        "In dashboard with no active session. So prompting to sign in again..")
    print(helperHTML.get_html_invalid_session_preset())
    print(helperHTML.get_html_end_preset())
    sys.exit()
mlog.debug(TAG, "In dashboard with active session..")
try:
    mlog.debug(TAG, "Establishing database connection..")
    conn = mysql.connector.connect(**config)
    cursor = conn.cursor()
except Exception as e:
    mlog.error(TAG, "Unable to conenct to MyBanking Database.")
Esempio n. 26
0
 def transfer_to(self, account, amount):
     mlog.debug(self.TAG, "transfer_to(" + str(amount) + ")")
     if account is None:
         mlog.debug(self.TAG,
                    "transfer_to(None," + str(amount) + ") failed.!")
         return False
     if int(amount) <= 0:
         mlog.debug(
             self.TAG, "transfer_to(" + str(account.number) + "," +
             str(amount) + ") failed.")
         return False
     mlog.debug(
         self.TAG,
         "transfer_to(" + str(account.number) + "," + str(amount) + ")")
     transferred = self.debit(amount)
     mlog.debug(self.TAG, "Status of transfer:" + str(transferred))
     if transferred == True:
         mlog.debug(self.TAG, "Depositing to target account..")
         account.deposit(amount)
     mlog.debug(self.TAG, "Transfer process completed!")
     return transferred
Esempio n. 27
0
#!"C:/Python34/python.exe"

import cgi, cgitb
import mysql.connector
import sys
import helperHTML
import helperSession
from database.db_config import config
import mlog

TAG = "DO_REMOVE_PAYEE"
mlog.debug(TAG, "Trying to remove payee..")
cgitb.enable()
print(helperHTML.get_html_init())
print(helperHTML.get_html_start_preset())

if (helperSession.any_session_active() == False):
    #Show session inactive..
    mlog.debug(
        TAG,
        "In show_remomve_payee with no active session. So prompting to sign in again.."
    )
    print(helperHTML.get_html_invalid_session_preset())
    print(helperHTML.get_html_end_preset())
    sys.exit()

#ELSE: Show list of payees to remove
account_number = helperSession.get_session_accout_no()

try:
    mlog.debug(TAG, "Establishing database connection..")
Esempio n. 28
0
 def can_debit(self, amount):
     mlog.debug(self.TAG, "can_debit(" + str(amount) + ")")
     if int(amount) > 0 and int(balance) > int(amount):
         return True
     else:
         return False
Esempio n. 29
0
 def deposit(self, amount):
     mlog.debug(self.TAG, "deposit(" + str(amount) + ")")
     if int(amount) > 0:
         self.balance += int(amount)
Esempio n. 30
0
    def gen_vcxproj(self, target, ofname, guid, compiler):
        mlog.debug('Generating vcxproj %s.' % target.name)
        entrypoint = 'WinMainCRTStartup'
        subsystem = 'Windows'
        if isinstance(target, build.Executable):
            conftype = 'Application'
            if not target.gui_app:
                subsystem = 'Console'
                entrypoint = 'mainCRTStartup'
        elif isinstance(target, build.StaticLibrary):
            conftype = 'StaticLibrary'
        elif isinstance(target, build.SharedLibrary):
            conftype = 'DynamicLibrary'
            entrypoint = '_DllMainCrtStartup'
        elif isinstance(target, build.CustomTarget):
            return self.gen_custom_target_vcxproj(target, ofname, guid)
        elif isinstance(target, build.RunTarget):
            return self.gen_run_target_vcxproj(target, ofname, guid)
        else:
            raise MesonException('Unknown target type for %s' % target.get_basename())
        down = self.target_to_build_root(target)
        proj_to_src_root = os.path.join(down, self.build_to_src)
        proj_to_src_dir = os.path.join(proj_to_src_root, target.subdir)
        (sources, headers) = self.split_sources(target.sources)
        buildtype = self.buildtype
        project_name = target.name
        target_name = target.name
        root = ET.Element('Project', {'DefaultTargets' : "Build",
                                      'ToolsVersion' : '4.0',
                                      'xmlns' : 'http://schemas.microsoft.com/developer/msbuild/2003'})
        confitems = ET.SubElement(root, 'ItemGroup', {'Label' : 'ProjectConfigurations'})
        prjconf = ET.SubElement(confitems, 'ProjectConfiguration',
                                {'Include' : self.buildtype + '|' + self.platform})
        p = ET.SubElement(prjconf, 'Configuration')
        p.text= buildtype
        pl = ET.SubElement(prjconf, 'Platform')
        pl.text = self.platform
        globalgroup = ET.SubElement(root, 'PropertyGroup', Label='Globals')
        guidelem = ET.SubElement(globalgroup, 'ProjectGuid')
        guidelem.text = guid
        kw = ET.SubElement(globalgroup, 'Keyword')
        kw.text = self.platform + 'Proj'
        ns = ET.SubElement(globalgroup, 'RootNamespace')
        ns.text = target_name
        p = ET.SubElement(globalgroup, 'Platform')
        p.text= self.platform
        pname= ET.SubElement(globalgroup, 'ProjectName')
        pname.text = project_name
        ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.Default.props')
        type_config = ET.SubElement(root, 'PropertyGroup', Label='Configuration')
        ET.SubElement(type_config, 'ConfigurationType').text = conftype
        ET.SubElement(type_config, 'CharacterSet').text = 'MultiByte'
        ET.SubElement(type_config, 'WholeProgramOptimization').text = 'false'
        ET.SubElement(type_config, 'UseDebugLibraries').text = 'true'
        ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.props')
        generated_files = self.generate_custom_generator_commands(target, root)
        (gen_src, gen_hdrs) = self.split_sources(generated_files)
        direlem = ET.SubElement(root, 'PropertyGroup')
        fver = ET.SubElement(direlem, '_ProjectFileVersion')
        fver.text = self.project_file_version
        outdir = ET.SubElement(direlem, 'OutDir')
        outdir.text = '.\\'
        intdir = ET.SubElement(direlem, 'IntDir')
        intdir.text = os.path.join(self.get_target_dir(target), target.get_basename() + '.dir') + '\\'
        tname = ET.SubElement(direlem, 'TargetName')
        tname.text = target_name
        inclinc = ET.SubElement(direlem, 'LinkIncremental')
        inclinc.text = 'true'

        compiles = ET.SubElement(root, 'ItemDefinitionGroup')
        clconf = ET.SubElement(compiles, 'ClCompile')
        opt = ET.SubElement(clconf, 'Optimization')
        opt.text = 'disabled'
        inc_dirs = [proj_to_src_dir, self.get_target_private_dir_abs(target)]
        cur_dir = target.subdir
        if cur_dir == '':
            cur_dir= '.'
        inc_dirs.append(cur_dir)
        extra_args = []
        # SUCKS, VS can not handle per-language type flags, so just use
        # them all.
        extra_args += compiler.get_buildtype_args(self.buildtype)
        for l in self.environment.coredata.external_args.values():
            for a in l:
                extra_args.append(a)
        for l in self.build.global_args.values():
            for a in l:
                extra_args.append(a)
        for l in target.extra_args.values():
            for a in l:
                extra_args.append(a)
        # FIXME all the internal flags of VS (optimization etc) are represented
        # by their own XML elements. In theory we should split all flags to those
        # that have an XML element and those that don't and serialise them
        # properly. This is a crapton of work for no real gain, so just dump them
        # here.
        extra_args = compiler.get_option_compile_args(self.environment.coredata.compiler_options)
        if len(extra_args) > 0:
            extra_args.append('%(AdditionalOptions)')
            ET.SubElement(clconf, "AdditionalOptions").text = ' '.join(extra_args)
        for d in target.include_dirs:
            for i in d.incdirs:
                curdir = os.path.join(d.curdir, i)
                inc_dirs.append(self.relpath(curdir, target.subdir)) # build dir
                inc_dirs.append(os.path.join(proj_to_src_root, curdir)) # src dir
        inc_dirs.append('%(AdditionalIncludeDirectories)')
        ET.SubElement(clconf, 'AdditionalIncludeDirectories').text = ';'.join(inc_dirs)
        preproc = ET.SubElement(clconf, 'PreprocessorDefinitions')
        rebuild = ET.SubElement(clconf, 'MinimalRebuild')
        rebuild.text = 'true'
        rtlib = ET.SubElement(clconf, 'RuntimeLibrary')
        rtlib.text = 'MultiThreadedDebugDLL'
        funclink = ET.SubElement(clconf, 'FunctionLevelLinking')
        funclink.text = 'true'
        pch = ET.SubElement(clconf, 'PrecompiledHeader')
        warnings = ET.SubElement(clconf, 'WarningLevel')
        warnings.text = 'Level3'
        debinfo = ET.SubElement(clconf, 'DebugInformationFormat')
        debinfo.text = 'EditAndContinue'
        resourcecompile = ET.SubElement(compiles, 'ResourceCompile')
        ET.SubElement(resourcecompile, 'PreprocessorDefinitions')
        link = ET.SubElement(compiles, 'Link')
        # Put all language args here, too.
        extra_link_args = compiler.get_option_link_args(self.environment.coredata.compiler_options)
        extra_link_args += compiler.get_buildtype_linker_args(self.buildtype)
        for l in self.environment.coredata.external_link_args.values():
            for a in l:
                extra_link_args.append(a)
        for l in target.link_args:
            for a in l:
                extra_link_args.append(a)
        if len(extra_args) > 0:
            extra_args.append('%(AdditionalOptions)')
            ET.SubElement(link, "AdditionalOptions").text = ' '.join(extra_args)

        additional_links = []
        for t in target.link_targets:
            lobj = self.build.targets[t.get_id()]
            rel_path = self.relpath(lobj.subdir, target.subdir)
            linkname = os.path.join(rel_path, lobj.get_import_filename())
            additional_links.append(linkname)
        for o in self.flatten_object_list(target, down):
            assert(isinstance(o, str))
            additional_links.append(o)
        if len(additional_links) > 0:
            additional_links.append('%(AdditionalDependencies)')
            ET.SubElement(link, 'AdditionalDependencies').text = ';'.join(additional_links)
        ofile = ET.SubElement(link, 'OutputFile')
        ofile.text = '$(OutDir)%s' % target.get_filename()
        addlibdir = ET.SubElement(link, 'AdditionalLibraryDirectories')
        addlibdir.text = '%(AdditionalLibraryDirectories)'
        subsys = ET.SubElement(link, 'SubSystem')
        subsys.text = subsystem
        gendeb = ET.SubElement(link, 'GenerateDebugInformation')
        gendeb.text = 'true'
        if isinstance(target, build.SharedLibrary):
            ET.SubElement(link, 'ImportLibrary').text = target.get_import_filename()
        pdb = ET.SubElement(link, 'ProgramDataBaseFileName')
        pdb.text = '$(OutDir}%s.pdb' % target_name
        if isinstance(target, build.Executable):
            ET.SubElement(link, 'EntryPointSymbol').text = entrypoint
        targetmachine = ET.SubElement(link, 'TargetMachine')
        targetmachine.text = 'MachineX86'

        if len(headers) + len(gen_hdrs) > 0:
            inc_hdrs = ET.SubElement(root, 'ItemGroup')
            for h in headers:
                relpath = h.rel_to_builddir(proj_to_src_root)
                ET.SubElement(inc_hdrs, 'CLInclude', Include=relpath)
            for h in gen_hdrs:
                if isinstance(h, str):
                    relpath = h
                else:
                    relpath = h.rel_to_builddir(proj_to_src_root)
                ET.SubElement(inc_hdrs, 'CLInclude', Include = relpath)
        if len(sources) + len(gen_src) > 0:
            inc_src = ET.SubElement(root, 'ItemGroup')
            for s in sources:
                relpath = s.rel_to_builddir(proj_to_src_root)
                ET.SubElement(inc_src, 'CLCompile', Include=relpath)
            for s in gen_src:
                relpath =  self.relpath(s, target.subdir)
                ET.SubElement(inc_src, 'CLCompile', Include=relpath)
        ET.SubElement(root, 'Import', Project='$(VCTargetsPath)\Microsoft.Cpp.targets')
        # Reference the regen target.
        ig = ET.SubElement(root, 'ItemGroup')
        pref = ET.SubElement(ig, 'ProjectReference', Include=os.path.join(self.environment.get_build_dir(), 'REGEN.vcxproj'))
        ET.SubElement(pref, 'Project').text = self.environment.coredata.regen_guid
        tree = ET.ElementTree(root)
        tree.write(ofname, encoding='utf-8', xml_declaration=True)
        # ElementTree can not do prettyprinting so do it manually
        doc = xml.dom.minidom.parse(ofname)
        open(ofname, 'w').write(doc.toprettyxml())
        # World of horror! Python insists on not quoting quotes and
        # fixing the escaped &quot; into &amp;quot; whereas MSVS
        # requires quoted but not fixed elements. Enter horrible hack.
        txt = open(ofname, 'r').read()
        open(ofname, 'w').write(txt.replace('&amp;quot;', '&quot;'))
Esempio n. 31
0
#!"C:/Python34/python.exe"

import cgi, cgitb
import sys
import helperHTML
import helperSession
import mlog

TAG = "SHOW_ADD_PAYEE"
mlog.debug(TAG, "At show_add_payee!")
cgitb.enable()
print(helperHTML.get_html_init())
print(helperHTML.get_html_start_preset())

if (helperSession.any_session_active() == False):
    #Show session inactive..
    mlog.debug(
        TAG,
        "In add_payee with no active session. So prompting to sign in again..")
    print(helperHTML.get_html_invalid_session_preset())
    print(helperHTML.get_html_end_preset())
    sys.exit()

content = '''
    <div id="entry" >
        <a id="dashboard_menu_a" href="show_dashboard.py">Dashboard</a>
        <a id="dashboard_menu_a" href="show_remove_payee.py">Remove Payee</a>
        <a id="dashboard_menu_a" href="show_deposit_money.py">Deposit Money</a>
        <a id="dashboard_menu_a" href="show_money_transfer.py">Money Transfer</a>
        <a id="dashboard_menu_a" href="logout.py">Logout</a>
    </div>
Esempio n. 32
0
    def __init__(self, name, environment, kwargs):
        Dependency.__init__(self)
        self.required = kwargs.get('required', True)
        if 'native' in kwargs and environment.is_cross_build():
            want_cross = not kwargs['native']
        else:
            want_cross = environment.is_cross_build()
        self.name = name
        if PkgConfigDependency.pkgconfig_found is None:
            self.check_pkgconfig()

        self.is_found = False
        if not PkgConfigDependency.pkgconfig_found:
            if self.required:
                raise DependencyException('Pkg-config not found.')
            self.cargs = []
            self.libs = []
            return
        if environment.is_cross_build() and want_cross:
            if "pkgconfig" not in environment.cross_info.config["binaries"]:
                raise DependencyException('Pkg-config binary missing from cross file.')
            pkgbin = environment.cross_info.config["binaries"]['pkgconfig']
            self.type_string = 'Cross'
        else:
            pkgbin = 'pkg-config'
            self.type_string = 'Native'

        mlog.debug('Determining dependency %s with pkg-config executable %s.' % (name, pkgbin))
        self.pkgbin = pkgbin
        p = subprocess.Popen([pkgbin, '--modversion', name],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        out = p.communicate()[0]
        if p.returncode != 0:
            if self.required:
                raise DependencyException('%s dependency %s not found.' % (self.type_string, name))
            self.modversion = 'none'
            self.cargs = []
            self.libs = []
        else:
            self.modversion = out.decode().strip()
            mlog.log('%s dependency' % self.type_string, mlog.bold(name), 'found:',
                     mlog.green('YES'), self.modversion)
            self.version_requirement = kwargs.get('version', None)
            if self.version_requirement is None:
                self.is_found = True
            else:
                if not isinstance(self.version_requirement, str):
                    raise DependencyException('Version argument must be string.')
                self.is_found = mesonlib.version_compare(self.modversion, self.version_requirement)
                if not self.is_found and self.required:
                    raise DependencyException(
                        'Invalid version of a dependency, needed %s %s found %s.' %
                        (name, self.version_requirement, self.modversion))
            if not self.is_found:
                return
            p = subprocess.Popen([pkgbin, '--cflags', name], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate cargs for %s.' % name)
            self.cargs = out.decode().split()

            p = subprocess.Popen([pkgbin, '--libs', name], stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            out = p.communicate()[0]
            if p.returncode != 0:
                raise RuntimeError('Could not generate libs for %s.' % name)
            self.libs = []
            for lib in out.decode().split():
                if lib.endswith(".la"):
                    shared_libname = self.extract_libtool_shlib(lib)
                    shared_lib = os.path.join(os.path.dirname(lib), shared_libname)
                    if not os.path.exists(shared_lib):
                        shared_lib = os.path.join(os.path.dirname(lib), ".libs", shared_libname)

                    if not os.path.exists(shared_lib):
                        raise RuntimeError('Got a libtools specific "%s" dependencies'
                                           'but we could not compute the actual shared'
                                           'library path' % lib)
                    lib = shared_lib

                self.libs.append(lib)
#!/usr/bin/python3

import cgi, cgitb
import sys
import helperHTML
import helperSession
import mlog

TAG = "SHOW_REGISTER.py"
mlog.debug(TAG, "At show_register.py!")
cgitb.enable()
print(helperHTML.get_html_init())

if (helperSession.any_session_active() == True):
    #session active..Redirect to dashboard..
    mlog.debug(
        TAG, "In show_register.py with active session. So showing dashboard..")
    print(helperHTML.get_html_content_with_redirect("show_dashboard.py"))
    sys.exit()

#Dump register page content..
content = '''
    <h4>Register/Sign up:</h4>
    <form action="/do_register.py" method="post">
       <div id="entry">
            <label>Full Name</label>
            <input type="text" placeholder="Enter Full Name" name="full_name" required>
	   </div>
       <div id="entry">
            <label>Username</label>
            <input type="text" placeholder="Enter Username" name="login_name" required>
Esempio n. 34
0
#!"C:/Python34/python.exe"
import cgi, cgitb
import sys
import helperHTML
import helperSession
import mlog

TAG = "INDEX.py"
mlog.debug(TAG, "At index.py!")
cgitb.enable()
print(helperHTML.get_html_init())

#if(helperSession.any_session_active() == True):

helperSession.end_session()

#Dump login page content..
content = '''
    <h4>Login:</h4>
    <form action="do_login.py" method="post">
      <div id="entry">
        <label>Username</label>
        <input type="text" placeholder="Enter Username" name="login_name" required>
	  </div>
	  <div id="entry">
        <label>Password</label>
        <input type="password" placeholder="Enter Password" name="login_key" required>                
      </div>
      <div id="entry" >
        <button type="submit">Login</button>
      </div>
Esempio n. 35
0
#!/usr/bin/python3

import cgi, cgitb
import sys
import helperHTML
import helperSession
import mlog

TAG = "SHOW_DEPOSIT_MONEY"
mlog.debug(TAG, "At show_deposit_money!")
cgitb.enable()
print(helperHTML.get_html_init())
print(helperHTML.get_html_start_preset())

if (helperSession.any_session_active() == False):
    #Show session inactive..
    mlog.debug(
        TAG,
        "In show_deposit_money with no active session. So prompting to sign in again.."
    )
    print(helperHTML.get_html_invalid_session_preset())
    print(helperHTML.get_html_end_preset())
    sys.exit()

#Dump menu and sow form to add money..
content = '''
        <div id="entry" >
            <a id="dashboard_menu_a" href="show_dashboard.py">Dashboard</a>
            <a id="dashboard_menu_a" href="show_add_payee.py">Add Payee</a>
            <a id="dashboard_menu_a" href="show_remove_payee.py">Remove Payee</a>
            <a id="dashboard_menu_a" href="show_money_transfer.py">Money Transfer</a>
Esempio n. 36
0
 def process_kwargs(self, kwargs):
     self.sources = kwargs.get('input', [])
     if not isinstance(self.sources, list):
         self.sources = [self.sources]
     if 'output' not in kwargs:
         raise InvalidArguments('Missing keyword argument "output".')
     self.output = kwargs['output']
     if not isinstance(self.output, list):
         self.output = [self.output]
     for i in self.output:
         if not(isinstance(i, str)):
             raise InvalidArguments('Output argument not a string.')
         if '/' in i:
             raise InvalidArguments('Output must not contain a path segment.')
     if 'command' not in kwargs:
         raise InvalidArguments('Missing keyword argument "command".')
     cmd = kwargs['command']
     if not(isinstance(cmd, list)):
         cmd = [cmd]
     final_cmd = []
     for i, c in enumerate(cmd):
         if hasattr(c, 'held_object'):
             c = c.held_object
         if isinstance(c, str):
             final_cmd.append(c)
         elif isinstance(c, dependencies.ExternalProgram):
             final_cmd += c.get_command()
         elif isinstance(c, BuildTarget) or isinstance(c, CustomTarget):
             self.dependencies.append(c)
             final_cmd.append(c)
         elif isinstance(c, list):
             # Hackety hack, only supports one level of flattening. Should really
             # work to arbtrary depth.
             for s in c:
                 if not isinstance(s, str):
                     raise InvalidArguments('Array as argument %d contains a non-string.' % i)
                 final_cmd.append(s)
         else:
             raise InvalidArguments('Argument %s in "command" is invalid.' % i)
     self.command = final_cmd
     if 'install' in kwargs:
         self.install = kwargs['install']
         if not isinstance(self.install, bool):
             raise InvalidArguments('"install" must be boolean.')
         if 'install_dir' not in kwargs:
             raise InvalidArguments('"install_dir" not specified.')
         self.install_dir = kwargs['install_dir']
         if not(isinstance(self.install_dir, str)):
             raise InvalidArguments('"install_dir" must be a string.')
     else:
         self.install = False
     self.build_always = kwargs.get('build_always', False)
     if not isinstance(self.build_always, bool):
         raise InvalidArguments('Argument build_always must be a boolean.')
     extra_deps = kwargs.get('depends', [])
     if not isinstance(extra_deps, list):
         extra_deps = [extra_deps]
     for ed in extra_deps:
         while hasattr(ed, 'held_object'):
             ed = ed.held_object
         if not isinstance(ed, CustomTarget) and not isinstance(ed, BuildTarget):
             raise InvalidArguments('Can only depend on toplevel targets.')
         self.extra_depends.append(ed)
     depend_files = kwargs.get('depend_files', [])
     if not isinstance(depend_files, list):
         depend_files = [depend_files]
     for i in depend_files:
         if isinstance(i, (File, str)):
             self.depend_files.append(i)
         else:
             mlog.debug(i)
             raise InvalidArguments('Unknown type in depend_files.')
Esempio n. 37
0
#!"C:/Python34/python.exe"

import cgi, cgitb
import mysql.connector
import sys
import helperHTML
import helperSession
from database.db_config import config
import mlog
import datetime

TAG = "DO_DEPOSIT"
mlog.debug(TAG, "Trying to do deposit..")
cgitb.enable()
print(helperHTML.get_html_init())
print(helperHTML.get_html_start_preset())

#Validate session..
if (helperSession.any_session_active() == False):
    #Show session inactive..
    mlog.debug(
        TAG,
        "In do_deposit_money with no active session. So prompting to sign in again.."
    )
    print(helperHTML.get_html_invalid_session_preset())
    print(helperHTML.get_html_end_preset())
    sys.exit()

account_number = helperSession.get_session_accout_no()
deposit_amount = 0
mlog.debug(TAG, "Fetching form values..")
Esempio n. 38
0
#!"C:/Python34/python.exe"

import cgi, cgitb
import sys
import helperHTML
import helperSession
import mlog
import mysql.connector
from database.db_config import config

TAG = "SHOW_REGISTER.py"
mlog.debug(TAG, "At show_register.py!")
cgitb.enable()
print(helperHTML.get_html_init())

try:
    mlog.debug(TAG, "Establishing database connection..")
    conn = mysql.connector.connect(**config)
    cursor = conn.cursor()
except Exception as e:
    mlog.error(TAG, "Unable to conenct to MyBanking Database:" + str(e))
    print('''
            <h4>Unable to conenct to MyBanking Database.</h4>
            <div id="entry" >
                <a href="home.py">BACK</a>
            </div>
        ''')
    print(helperHTML.get_html_end_preset())
    sys.exit()

all_recs = None
Esempio n. 39
0
#!/usr/bin/python3

import cgi, cgitb
import _mysql
import sys
import helperHTML
import helperSession
import database.db_config as db_config
import mlog
from helperRegEx import Validator

TAG = "DO_RESET_PASSWORD"
mlog.debug(TAG, "Trying to reset password..")
cgitb.enable()
print(helperHTML.get_html_init())
print(helperHTML.get_html_start_preset())

print("<h4>Reset password status:</h4><br><br>")

login_name = ""
login_key = ""
login_key_confirm = ""
mlog.debug(TAG,"Fetching form values..")
try:
    form_entries = cgi.FieldStorage()
    login_name = form_entries.getvalue("login_name")
    login_key = form_entries.getvalue("login_key")
    login_key_confirm = form_entries.getvalue("login_key_confirm")
except Exception as e:
    mlog.error(TAG,"Error: " + str(e))