def VTiter(self, *parsedArgs, **envars):
        largs, dictargs = self.full_parse(parsedArgs)
        fromv = 0
        tov = None
        stepv = 1
        checkfirst = True
        query = 'select 1'
        con = None

        if 'from' in dictargs:
            fromv = int(dictargs['from'])
        if 'to' in dictargs:
            tov = int(dictargs['to'])
        if 'step' in dictargs:
            stepv = int(dictargs['step'])
        if 'checkfirst' in dictargs and dictargs['checkfirst'] in ('f', 'F',
                                                                   '0'):
            checkfirst = False
        if len(largs) >= 1:
            fromv = int(largs[0])
        if len(largs) >= 2:
            tov = int(largs[1])
        if len(largs) >= 3:
            stepv = int(largs[2])
        if len(largs) == 1:
            fromv = 1
            tov = int(largs[0]) + 1

        if functions.variables.execdb is None:
            con = functions.Connection('')
        else:
            con = functions.Connection(functions.variables.execdb)
        functions.register(con)

        if 'query' not in dictargs:
            raise functions.OperatorError(
                __name__.rsplit('.')[-1], "Needs a query")
        else:
            query = dictargs['query']
        yield [('C1', 'int')]

        if checkfirst:
            cur = con.cursor()
            res = list(cur.execute(query))
            cur.close()
            if len(res) == 0 or len(res[0]) == 0 or res[0][0] != 1:
                return

        yield (fromv, )

        while True:
            cur = con.cursor()
            res = list(cur.execute(query))
            cur.close()
            if len(res) == 0 or len(res[0]) == 0 or res[0][0] != 1:
                return
            fromv += 1
            if tov is not None and fromv >= tov:
                return
            yield (fromv, )
Beispiel #2
0
    def VTiter(self, *parsedArgs, **envars):
        largs, dictargs = self.full_parse(parsedArgs)
        fromv = 0
        tov = None
        stepv = 1
        checkfirst = True
        query = 'select 1'
        con = None

        if 'from' in dictargs:
            fromv = int(dictargs['from'])
        if 'to' in dictargs:
            tov = int(dictargs['to'])
        if 'step' in dictargs:
            stepv = int(dictargs['step'])
        if 'checkfirst' in dictargs and dictargs['checkfirst'] in ('f', 'F', '0'):
            checkfirst = False
        if len(largs) >= 1:
            fromv = int(largs[0])
        if len(largs) >= 2:
            tov = int(largs[1])
        if len(largs) >= 3:
            stepv = int(largs[2])
        if len(largs) == 1:
            fromv = 1
            tov = int(largs[0])+1

        if functions.variables.execdb is None:
            con = functions.Connection('')
        else:
            con = functions.Connection(functions.variables.execdb)
        functions.register(con)

        if 'query' not in dictargs:
            raise functions.OperatorError(__name__.rsplit('.')[-1], "Needs a query")
        else:
            query = dictargs['query']
        yield [('C1', 'int')]

        if checkfirst:
            cur = con.cursor()
            res = list(cur.execute(query))
            cur.close()
            if len(res) == 0 or len(res[0]) == 0 or res[0][0] != 1:
                return

        yield (fromv,)

        while True:
            cur = con.cursor()
            res = list(cur.execute(query))
            cur.close()
            if len(res) == 0 or len(res[0]) == 0 or res[0][0] != 1:
                return
            fromv += 1
            if tov is not None and fromv >= tov:
                return
            yield (fromv, )
def createConnection(db):
    try:
        if 'SQLITE_OPEN_URI' in apsw.__dict__:
            connection = functions.Connection(db, flags=apsw.SQLITE_OPEN_READWRITE | apsw.SQLITE_OPEN_CREATE | apsw.SQLITE_OPEN_URI)
        else:
            connection = functions.Connection(db)
        functions.register(connection)
        connection.enableloadextension(True)
    except Exception, e:
        exitwitherror(e)
Beispiel #4
0
def createConnection(db):
    try:
        if 'SQLITE_OPEN_URI' in apsw.__dict__:
            connection = functions.Connection(db, flags=apsw.SQLITE_OPEN_READWRITE | apsw.SQLITE_OPEN_CREATE | apsw.SQLITE_OPEN_URI)
        else:
            connection = functions.Connection(db)
        functions.register(connection)
        connection.enableloadextension(True)
    except Exception, e:
        exitwitherror(e)
Beispiel #5
0
def get_register():
    #logout of any session first
    if not session.get("user_id") == None:
        session.clear()
    if request.method == 'GET':
        return render_template('register.html')

    elif request.method == 'POST':
        if not request.form.get("username"):
            return "You did not enter a username"
        elif not request.form.get("password"):
            return "You did not enter a password"
        elif not request.form.get("confirm_password"):
            return "You did not re-enter a password"

        if not request.form.get("password") == request.form.get(
                "confirm_password"):
            return "Passwords did not match"
        submitted_username, submitted_pass = request.form.get(
            "username"), request.form.get("password")
        #register functions returns bool depending on if theres a duplicate username, so True if name is available
        if functions.register(submitted_username, submitted_pass):
            #auto login after registering
            session["user_id"] = str(functions.get_user_id(submitted_username))
            session["username"] = submitted_username
            return redirect('/')
        else:
            return "Account name is taken"
Beispiel #6
0
def command_register(message):
    user_name = message.from_user.username
    chat_id = message.chat.id
    if functions.register(user_name, chat_id) == False:
        bot.send_message(message.chat.id,
                         "@" + user_name + " уже зарегистрирован!")
    else:
        bot.send_message(message.chat.id, "@" + user_name + " теперь в игре")
Beispiel #7
0
def main():
    while True:
        choice = input("Do you want to register or login?")
        if choice == "register":
            functions.register()
        elif choice == 'login':
            print("Player 1 please login")
            player1 = functions.login()
            print("Player 2 please login")
            player2 = functions.login()

            Player1Roll = functions.roll(player1)
            Player2Roll = functions.roll(player2)

            functions.decisive(Player1Roll, Player2Roll, player1, player2)
        else:
            print('Wrong keyword, please try again.')
Beispiel #8
0
def display_register():
    email, fullname, birth_of_date, username, password, lives_in = "", "", "", "", "", ""
    sex = 1
    flag = 0
    while True:
        if is_email_validated(email):
            if is_email_existed(email):
                print "email account have existed. Please enter other email !!"
                email = ""
            else:
                if len(fullname) > 0:
                    if flag:
                        pass
                    else:
                        try:
                            print "(Sex) 0 -> male,1 -> female, Other"
                            sex = int(raw_input('Sex:\t'))
                            print "lives in can be empty"
                            lives_in = raw_input("lives_in:\t")
                            flag = 1
                        except Exception as Ex:
                            print(Ex)
                            return -1
                    if validate_date(birth_of_date):
                        if len(username) > 0:
                            if validate_password(password):
                                confirm_password = raw_input(
                                    "confirm_password:\t")
                                if confirm_password == password:
                                    password = encrypt_string(password)
                                    if register(email, fullname, birth_of_date,
                                                sex, username, password,
                                                lives_in):
                                        print "Register successfully"
                                        break
                                    else:
                                        print "Can not register"
                                        break
                                else:
                                    print "Password confirmation doesn't match password"
                            else:
                                password = raw_input("Password:\t")
                        else:
                            username = raw_input("Username:\t")
                            if len(username) < 0:
                                print " username is empty. Please enter your username"
                    else:
                        birth_of_date = raw_input("Date of birth:\t")
                else:
                    fullname = raw_input("Fullname:\t")
                    if len(fullname) < 0:
                        print " fullname is empty. Please enter your fullname"
        else:
            email = raw_input("email:\t")
            if not is_email_validated(email):
                print "email is invalidated. Please enter email again!!"
Beispiel #9
0
def clientthread(conn, addr):
    conn.send(
        'Service Started. Choose an option Useing Uppercase letter\n #(R)egister\n #(U)pload files\n #(S)earch for a file\n #(E)xit'
    )
    onlinePeers.append(addr[0])
    while True:
        data = conn.recv(1024)

        if not data:
            continue
        elif data.split('\n')[0] == 'REGISTER':
            functions.register(conn, addr, data.split('\n')[1], str(addr[1]))
            # functions.register(conn, addr, "client" + str(addr[1]))
        elif data.split('\n')[0] == 'SHARE_FILES':
            functions.share(conn, addr, data.split('\n')[1], str(addr[1]))
        elif data.split('\n')[0] == 'SEARCH':
            functions.search(conn, addr, data.split('\n')[1], onlinePeers)

    onlinePeers.remove(addr[0])
    conn.close()
Beispiel #10
0
def clientthread(conn,addr):
	conn.send('Welcome to the server. Select an option\n 1. (R)egister\n 2. (U)pload files\n 3. (S)earch for a file\n 4. (E)xit')
	activePeers.append(addr[0])
	#print activePeers
	while 1: 
	    data = conn.recv(1024)
	    #reply = 'OK...' + data
	    if not data:
	    	break

	    if data.split('\n')[0] == 'REGISTER':
	    	functions.register(conn, addr, data.split('\n')[1])
	    elif data.split('\n')[0] == 'SHARE_FILES':
	    	functions.share(conn,addr,data.split('\n')[1])
	    elif data.split('\n')[0] == 'SEARCH':
	    	functions.search(conn,addr,data.split('\n')[1],activePeers)
	    elif data == 'TEST':
	    	functions.checkDB(conn)

	activePeers.remove(addr[0])
	conn.close()
Beispiel #11
0
def clientthread(conn, addr):
    conn.send(
        'Welcome to the server. Select an option\n 1. (R)egister\n 2. (U)pload files\n 3. (S)earch for a file\n 4. (E)xit'
    )
    activePeers.append(addr[0])
    #print activePeers
    while 1:
        data = conn.recv(1024)
        #reply = 'OK...' + data
        if not data:
            break

        if data.split('\n')[0] == 'REGISTER':
            functions.register(conn, addr, data.split('\n')[1])
        elif data.split('\n')[0] == 'SHARE_FILES':
            functions.share(conn, addr, data.split('\n')[1])
        elif data.split('\n')[0] == 'SEARCH':
            functions.search(conn, addr, data.split('\n')[1], activePeers)
        elif data == 'TEST':
            functions.checkDB(conn)

    activePeers.remove(addr[0])
    conn.close()
Beispiel #12
0
def registration():
    form = RegistrationForm()
    if form.validate_on_submit():
        name = form.name.data
        link = form.link.data
        promo = form.promo.data
        result = register(name, link, promo)
        hexa = result['hex']
        answer = data_entry(result)
        searches = searche()
        if answer == "SUCCESS!":
            return render_template('home.html',
                                   answer=answer,
                                   hexa=hexa,
                                   search=searches)
        else:
            return render_template('home.html', answer=answer, search=searches)
    return render_template('registration.html', form=form)
Beispiel #13
0
#Registration Process
print("Checking register")
history = check_history(worker["account"], register_config["account"])
if history is not None:
    if int(history["amount"]) == register_config["sign_new_account_code"]:
        print("Found your worker account registration: " + worker["account"])
        myIP = get_my_ip()  #check IP register
        ip_account = encode_ip(myIP)
        history = check_history(worker["account"], ip_account)
        if history is not None:
            print("Found your actuall IP address registration: " + myIP)
            if int(history["amount"]) != register_config["sign_new_ip_code"]:
                print("Incorrect amount in your IP address register")
                try_r = register(worker["account"], worker["representative"],
                                 frontier(worker["account"]), ip_account,
                                 register_config["sign_new_ip_code"], 1.0)
                if (try_r is False):
                    quit()
        else:
            print("Not found your actuall IP address registration: " + myIP)
            try_r = register(worker["account"], worker["representative"],
                             frontier(worker["account"]), ip_account,
                             register_config["sign_new_ip_code"], 1.0)
            if (try_r is False):
                quit()
    else:
        print("Incorrect amount in register")
        try_r = register(worker["account"], worker["representative"],
                         frontier(worker["account"]),
                         register_config["account"],
Beispiel #14
0
import functions

print("\n1. Login\n" "2. Register\n")
option = input("Please select an option: ")

if (option == "2"):
    username = input("Enter E-mail ID: ")
    password = input("Enter Password: "******"customer"
    myresult = functions.register(username, password, stamp)
    if (myresult == None):
        name = input(
            "\n\n\nRegistered Successfully\n\n\nWelcome new user \n\nEnter Name: "
        )
        location = input("Enter location: ")
        functions.insert_customer(name, location, username)

if (option == "1"):
    username = input("Enter E-mail ID: ")
    password = input("Enter Password: "******"customer"
    flag = functions.login(username, password, stamp)
    if (flag == 1):
        info = functions.account(username)
        print("\n\nWelcome back " + info[0] +
              ". \n\nHere are the barbers from " + info[1] + " location.\n\n")
        functions.customer_barber(info[1])
Beispiel #15
0
def execflow(diter, schema, connection, *args, **kargs):
    ignoreflag = 'ignorefail'

    if functions.variables.execdb is None:
        functions.variables.execdb = connection.filename
    con = functions.Connection(functions.variables.execdb)

    functions.register(con)
    oldvars = functions.variables
    newvars = lambda x: x
    newpath = None
    path = os.getcwd()

    if 'path' in kargs:
        newpath = os.path.abspath(kargs['path'])
        del kargs['path']
        os.chdir(newpath)

    newvars.execdb = functions.variables.execdb
    newvars.flowname = 'notset'
    for v in args:
        if hasattr(functions.variables, v):
            newvars.__dict__[v] = functions.variables.__dict__[v]
        else:
            raise functions.OperatorError(__name__.rsplit('.')[-1], "Variable %s doesn't exist" % (v,))
    for newv, oldv in kargs.items():
        if hasattr(functions.variables, oldv):
            newvars.__dict__[newv] = functions.variables.__dict__[oldv]
        else:
            raise functions.OperatorError(__name__.rsplit('.')[-1], "Variable %s doen't exist" % (oldv,))
    functions.variables = newvars

    if functions.settings['logging']:
        lg = logging.LoggerAdapter(logging.getLogger(__name__), {"flowname": functions.variables.flowname})
        lg.info("############FLOW START###################")
    before = datetime.datetime.now()

    query = ''
    try:
        line = 0
        for t in diter:
            for query in breakquery(t):
                line += 1
                if type(query) not in types.StringTypes:
                    raise functions.OperatorError(__name__.rsplit('.')[-1], "Content is not sql query")
                # Skip empty queries or comment lines
                query = query.strip()
                if query.startswith("--"):
                    continue
                cmatch = comment_line.match(query)
                if query == '' or (cmatch is not None and cmatch.groups()[0] == ''):
                    continue

                if functions.settings['logging']:
                    lg = logging.LoggerAdapter(logging.getLogger(__name__), {"flowname": functions.variables.flowname})
                    lg.info("STARTING: %s" % (query))
                before = datetime.datetime.now()
                c = con.cursor()
                # check ignore flag
                catchexception = False
                if query.startswith(ignoreflag):
                    catchexception = True
                    query = query[len(ignoreflag):]
                try:
                    for i in c.execute(query):
                        pass
                except Exception, e:  # Cathing IGNORE FAIL EXCEPTION
                    if catchexception:
                        if functions.settings['logging']:
                            lg = logging.LoggerAdapter(logging.getLogger(__name__),
                                                       {"flowname": functions.variables.flowname})
                            lg.exception("Ignoring Exception: " + str(e))
                        continue
                    else:
                        try:
                            c.close()
                            c = con.cursor()
                            c.execute('rollback')
                        except:
                            pass
                        raise e

                if functions.settings['logging']:
                    lg = logging.LoggerAdapter(logging.getLogger(__name__), {"flowname": functions.variables.flowname})
                    after = datetime.datetime.now()
                    tmdiff = after - before
                    duration = "%s min. %s sec %s msec" % ((
                    int(tmdiff.days) * 24 * 60 + (int(tmdiff.seconds) / 60), (int(tmdiff.seconds) % 60),
                    (int(tmdiff.microseconds) / 1000)))
                    lg.info("FINISHED in %s: %s" % (duration, query))
                c.close()
    except Exception, e:
        if functions.settings['logging']:
            lg = logging.LoggerAdapter(logging.getLogger(__name__), {"flowname": functions.variables.flowname})
            lg.exception(e)
        raise functions.OperatorError(__name__.rsplit('.')[-1],
                                      "Error in statement no. %s query '%s':\n%s" % (line, query, str(e)))
def register_route():
    if request.method == "POST":
        if request.is_json:
            return jsonify(
                register(request.json["email"], request.json["password"],
                         cursor, con))
Beispiel #17
0
        loggedIn = False
        UserID = ""

        while not loggedIn:
            loginOrRegister = input(
                "Please login (using your userID), register, or exit: L = Login, R = Register, E = Exit: "
            )
            if loginOrRegister.upper() == 'L':
                userObject = api.login(mycursor)
                if (userObject["success"]):
                    loggedIn = True
                    UserID = userObject["userID"]
                    break
            elif loginOrRegister.upper() == 'R':
                api.register(mycursor, mydb)
            elif loginOrRegister.upper() == 'E':
                print("Goodbye.")
                executing = False
                break
            else:
                print("That is not one of the options.")

        if loggedIn:
            while True:
                action = input(
                    "Main Menu:\nP = Post Menu\nF = Friend Menu\nG = Group Menu\nL = Logout\nE = Exit the Application\nWhich menu do you want? "
                )

                if action.upper() == 'E':
                    executing = False
Beispiel #18
0
    def VTiter(self, *parsedArgs, **envars):

        # default  parsing
        largs, dictargs = self.full_parse(parsedArgs)
        # print largs
        # print dictargs

        # get default connection
        connection = envars['db']
        if functions.variables.execdb is None:
            functions.variables.execdb = connection.filename
        tconnection = functions.Connection(functions.variables.execdb)
        functions.register(tconnection)

        # get query
        if 'query' not in dictargs:
            raise functions.OperatorError(__name__.rsplit('.')[-1], "No query argument.")
            # print "error 1"
        else:
            query = dictargs['query']

        # set up variables
        oldvars = functions.variables
        newvars = lambda x: x
        newpath = None
        path = os.getcwd()
        if 'path' in dictargs:
            newpath = os.path.abspath(dictargs['path'])
            del dictargs['path']
            os.chdir(newpath)
        newvars.execdb = functions.variables.execdb
        newvars.flowname = 'notset'

        for key in largs:
            if hasattr(functions.variables, key):
                setattr(newvars, key, getattr(functions.variables, key))
            else:
                raise functions.OperatorError(__name__.rsplit('.')[-1], "Variable %s doesn't exist" % (key,))
                # print "error 2"
        for key, value in dictargs.items():
            setattr(newvars, key, value)
        functions.variables = newvars

        # execute target queries
        try:
            counter = -1
            cursor = connection.cursor()
            tcursor = tconnection.cursor()
            tqlast = ''
            databases = cursor.execute("PRAGMA database_list")
            for database in databases:
                dbname = database[1]
                dbfile = database[2]
                if dbname != "main" and dbname != "mem" and dbname != "temp" and dbfile != '':
                    list(tcursor.execute("attach database '{0}' as {1};".format(dbfile, dbname)))

            counter = 0
            results = cursor.execute(query, parse=False)
            for result in results:
                for tquery in breakquery(result):
                    # print "tquery", tquery
                    # print "tqlast", tqlast
                    if tqlast != '':
                        list(tcursor.execute(tqlast))
                        counter += 1
                    tqlast = tquery
            # print "tqlast", len(tqlast)
            if len(tqlast) > 0:
                tresults = tcursor.execute(tqlast)
                counter += 1

                # print 'lala3'
                try:
                    yield tcursor.getdescriptionsafe()
                except apsw.ExecutionCompleteError:
                    try:
                        raise
                    finally:
                        try:
                            tcursor.close()
                            tconnection.close()
                            cursor.close()
                        except:
                            pass
                else:
                    for tresult in tresults:
                        yield tresult
            else:
                yield ('c1',)
            tcursor.close()
            tconnection.close()
            cursor.close()
        except Exception as ex:
            import traceback
            traceback.print_exc()
            raise functions.OperatorError(__name__.rsplit('.')[-1], "Error in query no. %d - %s" % (counter, str(ex)))
            # print "error 3"
        # restore env
        functions.variables = oldvars
        if newpath:
            os.chdir(path)
Beispiel #19
0
import sys, os
sys.path.append((os.path.join(sys.path[0], '..')))

import functions
from shutil import copyfile

functions.register()

curpath = os.path.abspath(sys.path[0])


def gendoc(funtype, toplevelonly=False):
    file = open(os.path.join(curpath, 'source', funtype + '.txt'), 'w')

    tmpstr = ".. _" + (funtype.lower() + ' functions list:').replace(
        ' ', '-') + '\n\n'
    tmpstr += funtype[0].upper() + funtype[1:] + ' functions list'
    file.write(tmpstr + '\n')
    file.write('=' * len(tmpstr) + '\n\n')
    file.write('.. automodule:: functions.' + funtype + '.__init__\n\n')

    docs = {}

    if not toplevelonly:
        for i, v in functions.functions[funtype].iteritems():
            if not v.__name__.startswith('functionslocal'):
                if v.__module__ not in docs:
                    docs[v.__module__] = []
                docs[v.__module__].append(i)
    else:
        for i, v in functions.functions[funtype].iteritems():
Beispiel #20
0
        quit()

#Registration Process
print ("Checking register")
history = check_history(worker_account, general_account)
if history is not None:
    if int(history["amount"]) == sign_new_account_code:
        print ("Found your worker account registration: " + worker_account)
        myIP = get_my_ip() #check IP register
        ip_account = encode_ip(myIP)
        history = check_history(worker_account, ip_account)
        if history is not None:
            print ("Found your actuall IP address registration: " + myIP)
            if int(history["amount"]) != sign_new_ip_code:
                print ("Incorrect amount in your IP address register")
                register (worker_account, worker_representative, frontier(worker_account), ip_account, sign_new_ip_code, 1.0)
        else:
            print ("Not found your actuall IP address registration: " + myIP)
            register (worker_account, worker_representative, frontier(worker_account), ip_account, sign_new_ip_code, 1.0)
    else:
        print ("Incorrect amount in register")
        register (worker_account, worker_representative, frontier(worker_account), general_account, sign_new_account_code, 1.0)
else:
    print ("Not found your worker registration: " + worker_account)
    register (worker_account, worker_representative, frontier(worker_account), general_account, sign_new_account_code, 1.0)


#convert to raws
fee = int(min_fee * 1000000000000000000000000000000)

@app.route('/open_request', methods=['GET', 'POST'])
Beispiel #21
0
def create_context(register_functions=True):
    cont = context.Context()
    if register_functions:
        functions.register(cont)
    return context.Context(cont)
import sys, os
sys.path.append((os.path.join(sys.path[0],'..')))

import functions
from shutil import copyfile

functions.register()

curpath = os.path.abspath(sys.path[0])

def gendoc(funtype, toplevelonly=False):
    file=open(os.path.join(curpath, 'source', funtype+'.txt'),'w')

    tmpstr=".. _"+(funtype.lower()+' functions list:').replace(' ','-')+'\n\n'
    tmpstr+=funtype[0].upper()+funtype[1:]+' functions list'
    file.write(tmpstr+'\n')
    file.write('='*len(tmpstr)+'\n\n')
    file.write('.. automodule:: functions.'+funtype+'.__init__\n\n')

    docs={}

    if not toplevelonly:
        for i,v in functions.functions[funtype].iteritems():
            if not v.__name__.startswith('functionslocal'):
                if v.__module__ not in docs:
                    docs[v.__module__]=[]
                docs[v.__module__].append(i)
    else:
        for i,v in functions.functions[funtype].iteritems():
            if not v.__name__.startswith('functionslocal'):
                tstr='functions.vtable.'+i
Beispiel #23
0
 def reg(self, username, token):
     info = register(username, token)
     return info