""" Main program """ import sys from main import Main SOCKET_PORT = 10000 DB_FILE = "resources/database.db" def main(m): """ Main program """ while True: m.listen_new_connection() if __name__ == '__main__': m = Main(SOCKET_PORT, DB_FILE) try: main(m) except (KeyboardInterrupt, SystemExit): print('Bye!') finally: m.close_socket_connection() sys.exit(1) sys.exit(1)
def setUp(self): self.app = Main()
from main import Main, colors, Module import pygame, math, random main = Main("Example", bg=(210,210,210), fps=10) class ExampleModule(Module): def __init__(self): self.buttons = [] #end def dispatch(self, events, mouse): for e in events: if e.type == pygame.KEYDOWN and e.key == pygame.K_q: print("pressed q") main.quit() #end def setup(self, main): self.buttons += [main.addButton((400, 400), (120, 50), "start game", colors.blue, colors.green, lambda x: print(x))] #end #end main.addModule(ExampleModule()) main.run()
import streamlit as st from main import Main from apps import home, teori, implementasi st.set_page_config(layout="wide") app = Main() app.add_app("Home", home.app) app.add_app("Fuzzy Logic", teori.app) app.add_app("Implementasi Fuzzy Mamdani", implementasi.app) app.run()
def classFactory(iface): return Main(iface)
def call_main(self): m = Main(SS_HOTKEY, SS_DIRPATH, RING_HOTKEY, FOOD_HOTKEY, SOFT_HOTKEY, RUNE_HOTKEY, CHAR_NAME, CYCLE_TIME, RUNES_PER_CYCLE) m.main()
def setUp(self) -> None: self.mainObj = Main() self.nameTestCsv = 'Test/name_set.csv'
def test_no_remove(capsys): main = Main() main.remove_player("Bob") out, er = capsys.readouterr() assert "Can't have less than 2 players\n" == out
def test_random_color(): main = Main() col = main.random_color() assert (("b" == col) or ("y" == col))
def test_rename_no_such(capsys): main = Main() main.rename_player("Otto", "Oswald") out, err = capsys.readouterr() assert "No such player\n" == out
def test_rename(capsys): main = Main() main.rename_player("Alice", "Alex") out, err = capsys.readouterr() assert {Player("Alex", "g"), Player("Bob", "r")} == main.players assert "Renamed: Player(name='Alice', color='g')\n" == out
def search(self): if (self.timeLengthCombox.get() == '' or self.itemCombox.get() == ''): return main = Main(self, 2020, 1, 1, 2020, 1, 3, '台北一', self.itemCombox.get(), self.timeLengthCombox.get()) root.after(0, self.drawFigure, main)
import matplotlib.pyplot as plt from main import Main from setting import Setting # ここの下をいじる Setting.BETA = 0.3 Setting.GROUP_DIFFERENCE = 60 Setting.SYUYAKUDO = 8 main1 = Main() main1.run() main1_x = range(0, Setting.UPDATE_NUM) main1_y = main1.totalScores # ここの下をいじる Setting.BETA = 0.6 Setting.GROUP_DIFFERENCE = 60 Setting.SYUYAKUDO = 8 main2 = Main() main2.run() print(main2.totalScores) main2_x = range(0, Setting.UPDATE_NUM) main2_y = main2.totalScores plt.plot(main1_x, main1_y, label="main1") plt.plot(main2_x, main2_y, label="main2") plt.legend()
import math import sys, os sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/game") from main import Main import numpy as np from collections import deque, namedtuple from skimage import color, transform, exposure import random game = Main() memory = deque() from config import * import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F device = torch.device("cuda" if torch.cuda.is_available() else "cpu") class DQN(nn.Module): def __init__(self): super(DQN, self).__init__() self.conv1 = nn.Conv2d(img_channels, 32, kernel_size=8, stride=4) self.pool1 = nn.MaxPool2d(kernel_size=4, stride=2, padding=(4 - 1) // 2) self.conv2 = nn.Conv2d(32, 64, kernel_size=4, stride=2)
def test_sum(self): temp = Main() expected = 3 actual = temp.sum(1, 2) self.assertEqual(expected, actual)
def main(): """Runs Another Pong Clone Again game!""" apca = Main() apca.main()
from main import Main if __name__ == '__main__': Main()
from main import Main from account import Account from check import Check from user import User from person import Person admin = Main() usr1 = User('Martin12') usr2 = User('Juan34') usr3 = User('Lucas2') usr4 = User('Pepito22') c1 = Account(usr1) c2 = Account(usr2) c3 = Account(usr3) c4 = Account(usr4) admin.accountRegister(c1) admin.accountRegister(c2) admin.accountRegister(c3) admin.accountRegister(c4) p1 = Person('Martin', 'Borges', 'Av. de las americas') p2 = Person('Pepe', 'Ramiresz', 'Av. Jose Ing') p3 = Person('ELucas', 'Rodriguez', 'AV. andresito 129') p4 = Person('Pepe', 'Sas', 'Misiones 120') ch1 = Check('Para navidad', 2000, p1, p2) ch2 = Check('Para cumpleaños', 3000, p1, p2) ch3 = Check('Para FIESTA', 3000, p3, p2)
# model parameters ROOT_DIR = '' INPUT_SIZE = 52 OUTPUT_SIZE = 4 HIDDEN_SIZE = 128 NUM_LSTM_LAYERS = 2 BATCH_SIZE = 16 SEQUENCE_SIZE = 5 # run parameters LEARNING_RATE = 0.01 EPOCHS_NUMBER = 5000 # test parameters TEST_SAMPLES = 160 for p in range(5, 27): if p is not 20 and p is not 22: PARTICIPANT_NUMBER = p print('Evaluating participant ' + str(p) + '...') # run main = Main(ROOT_DIR, INPUT_SIZE, OUTPUT_SIZE, HIDDEN_SIZE, NUM_LSTM_LAYERS, BATCH_SIZE, SEQUENCE_SIZE) model, scaler = main.train(EPOCHS_NUMBER, LEARNING_RATE, PARTICIPANT_NUMBER) valid_loss, imposter_loss = main.test_stressed(model, scaler, PARTICIPANT_NUMBER, TEST_SAMPLES)
from main import Main from tkinter import messagebox as msg root = Main() def on_close(): if msg.askyesno("Quit", "Do You want to Quit?"): root.destroy() root.protocol("WM_DELETE_WINDOW", on_close) root.mainloop()
#!/usr/bin/env python3 from main import Main import nmap if __name__ == "__main__": hammer = Main() nmScan = nmap.PortScanner() nmScan.scan(hammer.args.ip, str(hammer.args.port)) #print(nmScan[str(hammer.args.ip)]['tcp'][hammer.args.port]['state']) #print(nmScan['192.168.1.110']['tcp'][445]['state']) if nmScan[str(hammer.args.ip)]['tcp'][hammer.args.port]['state'] == 'open': print(f'The port {hammer.args.port} is open') hammer.run(hammer.args.brute) #print(hammer.args.ip, hammer.args.port, hammer.args.user, hammer.args.passwd_file)
def __init__(self, master=None, title=None, message=None): """ Start the GUI and the asynchronous threads. We are in the main (original) thread of the application, which will later be used by the GUI. We spawn a new thread for the worker. """ self.master = master self.master.protocol("WM_DELETE_WINDOW", self.on_closing) self.master.bind("<Destroy>", None) self.modalPane = self.master # self.modalPane = Toplevel(self.master) # # self.modalPane.transient(self.master) # self.modalPane.grab_set() # self.modalPane.bind("<Escape>", self._cancel) if title: self.modalPane.title(title) if message: Label(self.modalPane, text=message).pack(padx=5, pady=5) # Button(self.modalPane, text='Iniciar Flora Brasil', command=self.run_flora).pack(padx=5, pady=5) Label(self.modalPane, text='Flora do Brasil').pack(padx=5, pady=5) self.flora = Progressbar(self.modalPane, orient="horizontal", length=200, mode="determinate") self.flora.pack() # Button(self.modalPane, text='Iniciar The Plant List', command=self.run_plant).pack(padx=5, pady=5) Label(self.modalPane, text='The Plant List').pack(padx=5, pady=5) self.plant = Progressbar(self.modalPane, orient="horizontal", length=200, mode="determinate") self.plant.pack() # Button(self.modalPane, text='Iniciar GBIF', command=self.run_gbif).pack(padx=5, pady=5) Label(self.modalPane, text='GBIF').pack(padx=5, pady=5) self.gbif = Progressbar(self.modalPane, orient="horizontal", length=200, mode="determinate") self.gbif.pack() # Button(self.modalPane, text='Iniciar Species Link', command=self.run_splink).pack(padx=5, pady=5) Label(self.modalPane, text='Species Link').pack(padx=5, pady=5) self.splink = Progressbar(self.modalPane, orient="horizontal", length=200, mode="determinate") self.splink.pack() # Button(self.modalPane, text='Relação Flora Brasil x The Plant List', command=self.run_flora_x_plant).pack( # padx=5, pady=5) listFrame = Frame(self.modalPane) listFrame.pack(side=TOP, padx=5, pady=5) scrollBar = Scrollbar(listFrame) scrollBar.pack(side=RIGHT, fill=Y) self.listBox = Listbox(listFrame, selectmode=SINGLE) self.listBox.pack(side=LEFT, fill=Y) self.listBox.bind('<Double-Button-1>', self.doubleclick) scrollBar.config(command=self.listBox.yview) self.listBox.config(yscrollcommand=scrollBar.set) buttonFrame = Frame(self.modalPane) buttonFrame.pack(side=BOTTOM) # Create the queue self.n_gbif = Queue() self.n_plant = Queue() self.n_flora = Queue() self.n_splink = Queue() self.files = Queue() self.list = [] # Set up the GUI part self.gui = [GuiPart(self.gbif, self.n_gbif, self.endApplication), GuiPart(self.plant, self.n_plant, self.endApplication), GuiPart(self.flora, self.n_flora, self.endApplication), GuiPart(self.splink, self.n_splink, self.endApplication), GuiPart(self.listBox, self.files, self.endApplication, self.list) ] # Set up the thread to do asynchronous I/O # More can be made if necessary self.main = Main(self.openCSV()) self.len_n_flora_plant = 0 self.running = 1 self.thread = [] self.run_flora() self.run_plant() self.run_Planilha_1() self.run_Planilha_2() self.run_gbif() self.run_splink() self.run_gbif_splink() # Start the periodic call in the GUI to check if the queue contains if not stop_event.is_set(): self.periodicCall()
# Parser für Kommandozeilenargumente parser = OptionParser() parser.add_option("-r", "--repository", dest="repository", help="GIT Repository to use", metavar="FOLDER") parser.add_option("-c", "--config", dest="config", help="Configuration ID to use") (options, args) = parser.parse_args() configuration = options.config repository = options.repository config_manager = ConfigManager() # Keine Konfiguration angegeben => Zeige Auswahl if not configuration: for i in config_manager.get_configs(): print(str(i[0]) + ": " + i[1]) configuration = input("Configuration: ") # Kein Repository-Pfad angegeben => Nimm Working Directory if not repository: repository = os.getcwd() print("Config: " + configuration) print("Repo: " + repository) main = Main(config_manager, int(configuration), repository)
def clustering_work(method, body): Main(body, rabbitmq_host, rabbitmq_port, matrix_buffer, fast_test).start() connection.add_callback_threadsafe( functools.partial(channel.basic_ack, method.delivery_tag))
from flask import Flask, render_template, request, redirect, url_for from main import Main app = Flask(__name__) main = Main() @app.route("/", methods=['GET']) def output(): input = main.input output = main.output label = main.label return render_template('compress_view.html', input=input, output=output, label=label) @app.route("/", methods=['POST']) def input(): if request.form['submit'] == 'encode': input = request.form['input'] main.encodeInput(input) elif request.form['submit'] == 'decode': input = request.form['input'] main.decodeInput(input) return redirect(url_for("output"))
def setUp(self): """Execute steps before each tests.""" self.napp = Main(get_controller_mock())
from kivy.uix.button import Button from kivy.uix.screenmanager import ScreenManager, Screen, WipeTransition from kivy.uix.image import Image from kivy.core.window import Window from kivy.config import Config from kivy.clock import Clock from main import Main import logging from PIL.ImageChops import screen # ==== global instances ==== app = None backend = Main() backend.start() # ==== SETTINGS ==== # # Config.set('kivy', 'log_enable', 1) # Config.set('kivy', 'log_level', 'debug') Config.set('graphics', 'width', '768') Config.set('graphics', 'height', '1366') Config.set('graphics', 'position', 'custom') Config.set('graphics', 'left', '30') Config.set('graphics', 'top', '30') Config.write() """ NOTES - first screen start without logic etc. TODO: either introduce a starting screen of tie in with Kivy logic
def __init__(self, connection=Main().connection()): self.connection = connection
import csv import json import os from main import Main stanfordpath = '../StanfordParser/' m = Main() for subdir, dirs, files in os.walk('../nlvr-master/test/images/'): for file in files: filepath = subdir + os.sep + file if filepath.endswith("-0.png"): m.main(filepath, stanfordpath)
from main import Main import traceback import sys # SUPER HACK - There are a few errors that will cause the function to error # but will succeed on a retry, i.e. no verb can be found in proverb, unable to lemmatize verb, # to hack round this for the moment, we just retry if we fail. error_count = 0 while error_count < 5: try: Main('English', 'French').main() break except Exception: print(traceback.format_exc()) # or print(sys.exc_info()[0])