Beispiel #1
0
def main(number_of_sessions=3):
    for i in range(
            number_of_sessions
    ):  # run the front end instance 3 times with appropriate inputs
        # prepare program parameters
        sys.argv = [
            'frontend.py', 'valid_accounts.txt',
            'new_transactions/transaction_' + str(i) + '.txt'
        ]
        frontend.main()
    temp_fd, temp_file = tempfile.mkstemp()
    merged_transaction_file = temp_file
    transaction_files = glob.glob(
        "new_transactions/*.txt")  # list of transaction summary files
    with open(merged_transaction_file,
              'w') as wf:  # create merged txn summary file
        for file in transaction_files:
            with open(file, 'r') as tf:
                for line in tf:
                    if line != 'EOS 0000000 000 0000000 ***':
                        wf.write(line)
        wf.write('EOS 0000000 000 0000000 ***')
    for transaction in transaction_files:
        os.remove(transaction)
    # run backend with updated files
    sys.argv = ['backend.py', 'master_accounts.txt', merged_transaction_file]
    backend.main()
    os.close(temp_fd)
    os.remove(temp_file)
def main(name="Rahul"):
    code = request.form["code"] if request.method == 'POST' else ""
    print(code)
    print(backend.main(code)[1].print_trace_table())
    return render_template('index.html',
                           name=name,
                           code=code,
                           table=backend.main(code)[1].print_trace_table())
Beispiel #3
0
 def input_button_clicked(self):
     values = self.get_data_from_widgets()
     if not all(val != "" for val in values):
         self.show_popup("Введіть значення параметрів!")
         self.is_added = False
     else:
         args = {k: v for k, v in zip(self.default_args.keys(), values)}
         backend.arg = args
         backend.main()
def run_backend(input_cities):
    # cleanup package
    reload(backend) 
    # prepare program parameters
    sys.argv = ['backend.py']
    for city in input_cities:
        sys.argv.append('transactions/' + city + "_transactions.csv")

    # run the program
    backend.main()
Beispiel #5
0
def index():
    if request.method == "GET":
        return render_template('index.html')

    elif request.method == "POST":
        print(request.form['main-input'])
        return (main(request.form['main-input']))
Beispiel #6
0
def executeButton():
    global registers
    global flags
    T3.delete('1.0', END)
    toPrint, registers, flags = backend.main(fileName)
    T3.insert(END, toPrint)
    showRegisters()
Beispiel #7
0
def dailySession():
    #reset all variables in the front end file
    reload(front_end)
    #call front end's main function
    front_end.main()

    infile = open("tsf.txt", "r")
    lines = infile.read().splitlines()

    outfile = open("tsf.txt", "w")
    #fix format of the merged tsf file, removing duplicate EOS lines
    for i in lines:
        if (i != "EOS 0000000 000 0000000 ***"):
            outfile.write(i + "\n")
    outfile.write("EOS 0000000 000 0000000 ***")
    outfile.close()

    #call back end's main function
    backend.main()
Beispiel #8
0
def hello():
    form = ReusableForm(request.form)
    if request.method == 'POST':
        name = request.form['name']
        print('Input entered: ', name)
        address, latitude, longitude, url = geolocate(name)
        if form.validate():
            if url is not None:
                flash('Your location is ' + address)
                print('Success! Address found: ', address)
                flash(main(longitude, latitude)[1])
            else:
                flash('Unable to locate address based on given input')
                print('Failure!')
        else:
            flash('All the form fields are required. ')
            print('Null input detected.')

    return render_template('hello.html', form=form)
Beispiel #9
0
def results():
    query = request.form['query']
    # query = query.capitalize()
    pos_per, neg_per, neg_tweets, pos_tweets = backend.main(query)

    query = query.capitalize()
    try:
        neut_per = 100 - (pos_per + neg_per)
    except TypeError:
        neut_per = "Not Available"
    if len(pos_tweets) == 0:
        pos_tweets = "Not Available"
    if len(neg_tweets) == 0:
        neg_tweets = "Not Available"
    return render_template('results.html',
                           query=query,
                           pos_tweets=pos_tweets,
                           neg_tweets=neg_tweets,
                           pos_per=pos_per,
                           neg_per=neg_per,
                           neut_per=neut_per)
Beispiel #10
0
size = width, height = 1200, 600
screen = pygame.display.set_mode(size)

# Fonts
# Can be changed to DMSerif if required
OLD_LONDON = "assets/fonts/OldLondon.ttf"
# OPEN_SANS = "assets/fonts/DMSerif.ttf"
smallFont = pygame.font.Font(OLD_LONDON, 20)
mediumFont = pygame.font.Font(OLD_LONDON, 28)
largeFont = pygame.font.Font(OLD_LONDON, 40)

# Add image as Background
scroll = pygame.image.load("assets/images/scroll.png")
scroll = pygame.transform.scale(scroll, (600, 450))

model = main()
lines = []
wait = ["", "", "", "", "", "", "Please Wait", "Loading..."]
lines = wait
newSonnet = True

while True:

    # Check if game quit
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()

    screen.fill(BLACK)

    # Draw the scroll
Beispiel #11
0
 def setUp(self):
     from backend import main
     app = main({})
     from webtest import TestApp
     self.testapp = TestApp(app)
Beispiel #12
0
		if ret != msg and 'your place in the queue is' in ret:
			if not 'global_push' in core['pickle_ignore']:
				core['pickle_ignore']['global_push'] = {}
			if not 'queue' in core['pickle_ignore']['global_push']:
				core['pickle_ignore']['global_push']['queue'] = [3, '']
			
			core['pickle_ignore']['global_push']['queue'][1] = core['pickle_ignore']['global_push']['queue'][1] + ';' + str(core['pickle_ignore']['queue'].settings['queuepos']) + ':unaccepted:'+identifier
			if core['pickle_ignore']['global_push']['queue'][1][0] == ';':
				core['pickle_ignore']['global_push']['queue'][1] = core['pickle_ignore']['global_push']['queue'][1][1:]

		return True

core['pickle_ignore']['parser'] = parser
#core['pickle_ignore']['twitter'] = twitterapi.twitt(['#DHSupport',])
core['pickle_ignore']['irc'] = ircapi.irc({'password' : __password__})
core['pickle_ignore']['backend'] = backend.main()
core['pickle_ignore']['queue'] = queue()
#core['pickle_ignore']['skype'] = skypeapi.Skype()
#core['pickle_ignore']['email'] = mailapi.Mail()
#core['pickle_ignore']['cco'] = ccoapi.CCO()

garbageman = __import__('cycle')
garbagehandle = garbageman.garbageman(core)
garbagehandle.start()

pid = getpid()
f = open(pidfile, 'wb')
f.write(str(pid))
f.close()

log('All instances started!')
def test_backend():
    mergeAllFiles()
    backend.main()
Beispiel #14
0
def helper(capsys,
           merged_transaction_summary,
           master_accounts_list,
           expected_output_master_accounts_file,
           expected_tail_of_terminal_output,
           expected_valid_accounts_file
           ):
    """Helper function for testing

    Arguments:
        capsys -- object created by pytest to capture stdout and stderr
        terminal_input -- list of string for terminal input
        expected_tail_of_terminal_output list of expected string at the tail of terminal
        input_valid_accounts -- list of valid accounts in the valid_account_list_file
        expected_output_transactions -- list of expected output transactions
    """

    # cleanup package
    reload(app)

    # create a temporary file in the system to store the valid accounts:
    temp_fd2, temp_file2 = tempfile.mkstemp()
    master_accounts_file = temp_file2
    with open(master_accounts_file, 'w') as wf:
        wf.write('\n'.join(master_accounts_list))
    temp_fd, temp_file = tempfile.mkstemp()
    merged_transaction_file = temp_file
    with open(merged_transaction_file, 'w') as wf:
        wf.write('\n'.join(merged_transaction_summary))

    # prepare program parameters
    sys.argv = [
        'backend.py',
        master_accounts_file,
        merged_transaction_file]
    # run the program
    app.main()

    out, err = capsys.readouterr()

    # split terminal output in lines
    out_lines = out.splitlines()
    # compare terminal outputs at the end.`
    for i in range(1, len(expected_tail_of_terminal_output) + 1):
        index = i * -1
        assert expected_tail_of_terminal_output[index] == out_lines[index]

    # compare transactions:
    with open(master_accounts_file, 'r') as of:
        content = of.read().splitlines()
        for ind in range(len(content)):
            assert content[ind] == expected_output_master_accounts_file[ind]
    with open('valid_accounts.txt', 'r') as of:
        content = of.read().splitlines()
        for ind in range(len(content)):
            assert content[ind] == expected_valid_accounts_file[ind]
    # clean up
    os.close(temp_fd)
    os.remove(temp_file)
    os.close(temp_fd2)
    os.remove(temp_file2)
Beispiel #15
0
 def get(self):
   self.render("index.html",tosend=main("world",self.request.host_url),section="World")
Beispiel #16
0
from tkinter import *
from backend import main
from functools import partial

functions = main()

functions.get_random_word()
functions.create_display_string()


def filling_alphabet(alphabet):
    functions.check_input(alphabet)
    textFrame['text'] = ''.join(functions.display_string)


#The Graphical User Interface

root = Tk()

textFrame = Label(root,
                  text=''.join(functions.display_string),
                  font=("Courier", 34))
textFrame.pack(side=TOP)
buttonTopFrame = Frame(root)
buttonTopFrame.pack(side=TOP)
buttonSecondFrame = Frame(root)
buttonSecondFrame.pack(side=TOP)
buttonThirdFrame = Frame(root)
buttonThirdFrame.pack(side=TOP)

button_a = Button(buttonTopFrame,
Beispiel #17
0
 def get(self):
   self.render("index.html",tosend=main("sports",self.request.host_url),section="Sports")
Beispiel #18
0
 def get(self):
   self.render("index.html",tosend=main("tech",self.request.host_url),section="Technology")
Beispiel #19
0
 def get(self):
   self.render("index.html",tosend=main("social",self.request.host_url),section="Social")
Beispiel #20
0
 def get(self):
   self.render("index.html",tosend=main("entertainment",self.request.host_url),section="Entertainment")
Beispiel #21
0
if __name__ == "__main__":  # pragma: nocover
    from backend import main
    main()
Beispiel #22
0
#!/usr/bin/env python
#
# Copyright 2014, Rackspace, US, Inc, Neill Cox
#
# This file is part of memberdb.
#
# memberdb is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# memberdb is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with memberdb.  If not, see <http://www.gnu.org/licenses/>.

import backend

if __name__ == '__main__':  # pragma: no cover
    backend.main()
Beispiel #23
0
 def update_weather(self, location):
     self.address = str(location[0])
     self.lon = float(location[1])
     self.lat = float(location[2])
     (rain_string, self.report), self.image, self.timestamp = backend.main(float(self.lon), float(self.lat))
     self.rain_activity_levels = rain_string[0]
Beispiel #24
0
	# [sg.Text("Sensitivity %")],
	# [sg.Slider(range = (0, 100),orientation="h",default_value=80,key="-SENSITIVTY-")],
	[sg.Text("Input")],
	[sg.Combo(b.get_io_devices()[0],readonly=True,default_value=b.get_io_devices()[0][0],key="-INPUT-")],
	[sg.Text("Output")],
	[sg.Combo(b.get_io_devices()[1],readonly=True,default_value=b.get_io_devices()[1][0],key="-OUTPUT-")],
	[sg.Text("Output 2")],
	[sg.Combo(["Disabled"] + b.get_io_devices()[1],readonly=True,default_value="Disabled",key="-OUTPUT2-")],
	[sg.Text("Say manually")],
	[sg.Input(key="-MANUAL-"),sg.Button("Say")],
	[sg.Button('Ok'), sg.Button('Quit')]
]
# Create the window
window = sg.Window('sttttts', layout,icon="logos\\icon.ico")
hk = SystemHotkey()
hk.register(('control', 'q'), callback=lambda x:b.main(None,None,None))
hk.register(('alt', 'q'), callback=lambda x:b.repeat(None,None))

# Display and interact with the Window using an Event Loop
while True:
	event, values = window.read()
	# See if user wants to quit or window was closed
	if event == sg.WINDOW_CLOSED or event == 'Quit':
		break
	devices = b.get_io_devices()
	wanted_input = devices[0].index(values["-INPUT-"])
	wanted_output = devices[1].index(values["-OUTPUT-"]) + len(devices[0])
	if values["-OUTPUT2-"] == "Disabled":
		wanted_output2 = None
	else:
		wanted_output2 = devices[1].index(values["-OUTPUT2-"]) + len(devices[0])
Beispiel #25
0
import backend
backend.main('-e', 'test')