コード例 #1
0
ファイル: __init__.py プロジェクト: danya-psch/db
 def choose_operation(self):
     while True:
         check = self._type_of_table == TypeOfTable.PLAYER__GAME or self._type_of_table == TypeOfTable.DEVELOPER_COMPANY__GAME;
         list_operations = ['Create', 'Read', 'Update', 'Delete', 'List all', 'Back']
         if check:
             list_operations = ['Create', 'List all', 'Back']
         operation = self._main_controller.make_choice(list_operations, self._type_of_table.value[0])
         if check:
             if operation == 0:
                 self.insert()
             elif operation == 1:
                 self.show_all()
             elif operation == 2:
                 break
         else:
             if operation == 0:
                 self.insert()
             elif operation == 1:
                 self.show(MainController.get_uint_value("Print id: "))
             elif operation == 2:
                 self.update(MainController.get_uint_value("Print id: "))
             elif operation == 3:
                 self.delete(MainController.get_uint_value("Print id: "))
             elif operation == 4:
                 self.show_all()
             elif operation == 5:
                 break
コード例 #2
0
ファイル: __init__.py プロジェクト: danya-psch/db
 def _get_values_for_model(self):
     input_values = {}
     exact_list_of_fields = list_of_fields[self._type_of_table]
     for name_of_field, type_of_field in exact_list_of_fields.items():
         if name_of_field != 'id':
             input_values[name_of_field] = MainController.get_value(f"Enter {Model.get_name_of_field(name_of_field)}: ", type_of_field)
     return input_values
コード例 #3
0
ファイル: __init__.py プロジェクト: danya-psch/db
 def choose_operation(self):
     while True:
         list_operations = ['Create', 'Read', 'Update', 'Delete', 'List all', 'Back']
         operation = self._main_controller.make_choice(list_operations, self._type_of_table.value[0])
         if operation == 0:
             self.insert()
         elif operation == 1:
             self.show(MainController.get_uint_value("Print id: "))
         elif operation == 2:
             self.update(MainController.get_uint_value("Print id: "))
         elif operation == 3:
             self.delete(MainController.get_uint_value("Print id: "))
         elif operation == 4:
             self.show_all()
         elif operation == 5:
             break
コード例 #4
0
 def __init__(self):
     uid = os.getuid()
     if uid != 0:
         print '请使用root用户操作'
         sys.exit(-1)
     self.welcome()
     self.quit_quit = False
     self.switch_queue = Queue.Queue(0)
     self.view_control_map = {
         'login': LoginController(),
         'bye': ByeController(),
         'main': MainController(),
     }
     self._init_db()
     logging.info('程序开始')
     Thread(target=self._watchdog_switch).start()
コード例 #5
0
	print(34 * '#')
	#TODO center main main
	print('# {0:^30} #'.format('WELCOME TO TERMINAL BANK'))
	print(34 * '#')
	print('# {0:<30} #'.format(''))
	print('# {0:<30} #'.format('Choose an option:'))
	print('# {0:<30} #'.format('1 - Login'))
	print('# {0:<30} #'.format('0 - Close'))
	print('# {0:<30} #'.format(''))
	print(34 * '#')
	print()
	print('Type your option:')

if __name__ == '__main__':
	
	controller = MainController()
	
	close_app = False
	while not close_app:
		BaseView.clear_screen()
		print_menu()
		choice = input()
		if choice == '0':
			close_app = True
		elif choice == '1':
			controller.start_session()
		else:
			BaseView.clear_screen()
			print('\nInvalid option.\n')
			print('Press ENTER to try again...')
			input()
コード例 #6
0
def main_ui():
    """ Main function. """
    # Create instances of the model and the controller
    view = MainView()
    model = None
    MainController(model=model, view=view)
コード例 #7
0
from controller.main_controller import MainController

if __name__ == '__main__':
    MainController.run()
コード例 #8
0
	def run(self):
		print(self.args.m)
		if self.args.m:
			MainController.hello()
コード例 #9
0
ファイル: main.py プロジェクト: ductri/game_programming-ass1
__author__ = 'tri'
from controller.event_controller import EventController
from controller.env_controller import EnvController
from controller.main_controller import MainController

import pygame
import time
import os

env_controller = EnvController()
event_controller = EventController()
main_controller = MainController(event_controller, env_controller)

# Control fps
clock = pygame.time.Clock()

# Intro
intro_sound = pygame.mixer.Sound('resources/Mr.ogg')
intro_sound.play()

start_time = time.time()
while time.time() - start_time < 11:
    main_controller.intro(clock)

background_music = pygame.mixer.Sound('resources/background_music.ogg')
background_music.play()

main_controller.init_game()
main_controller.prepare()

# Game loop
コード例 #10
0
ファイル: main.py プロジェクト: wizzdev-pl/iot-starter
def main():
    logging.debug("=== MAIN START ===")

    # Increase stack size per thread this increases micropython recursion depth
    _thread.stack_size(8192 * 2)

    # Read and parse configuration from config.json
    utils.init()

    controller = MainController()

    # Check if configuration via access point has to be started
    if not config.cfg.ap_config_done or wake_reason() == PIN_WAKE:
        logging.debug("AP_DONE: {}, wake_reason: {}".format(
            config.cfg.ap_config_done, wake_reason()))
        logging.debug("SSID: {}, Password: {}".format(config.cfg.ssid,
                                                      config.cfg.password))
        if config.cfg.ssid != 'ssid' and config.cfg.password != 'password':
            logging.debug("SSID and password aren't default. Try to connect")
            pass
        else:
            logging.debug("=== Entering configuration mode ===")

            event = MainControllerEvent(
                MainControllerEventType.CONFIGURE_ACCESS_POINT)
            controller.add_event(event)

    logging.debug("Main loop")
    # If the device is powered on, then actual time from NTP server must be downloaded

    if reset_cause() == HARD_RESET or reset_cause(
    ) == PWRON_RESET or reset_cause() == SOFT_RESET:
        event = MainControllerEvent(MainControllerEventType.TEST_CONNECTION)
        controller.add_event(event)

    # Print actual time
    event = MainControllerEvent(MainControllerEventType.PRINT_TIME)
    controller.add_event(event)

    # Read temperature and humidity from the sensor and return the data as JSON
    event = MainControllerEvent(MainControllerEventType.GET_SENSOR_DATA)
    controller.add_event(event)

    # Connect to WIFI and publish JSON with data to AWS via MQTT
    event = MainControllerEvent(MainControllerEventType.PUBLISH_DATA)
    controller.add_event(event)

    # Good night!
    event = MainControllerEvent(MainControllerEventType.GO_TO_SLEEP,
                                callback=None,
                                ms=config.cfg.data_publishing_period_in_ms)
    controller.add_event(event)

    controller.perform()
コード例 #11
0
__author__ = 'tri'
from controller.event_controller import EventController
from controller.env_controller import EnvController
from controller.main_controller import MainController
import pygame


env_controller = EnvController()
event_controller = EventController()
main_controller = MainController(event_controller, env_controller)

main_controller.init_game()

# Control fps
clock = pygame.time.Clock()

while not main_controller.quit_game:
    # Listen events
    event_controller.run()

    # Update screen
    main_controller.run()

    pygame.display.flip()

    # Approximately 60fps
    clock.tick(60)



pygame.quit()
コード例 #12
0
'''import psycopg2

connection = psycopg2.connect(host="localhost", port="5432", database="db_lab1", user="******", password="******")
cursor = connection.cursor()
cursor.execute("SELECT * FROM game")
row = cursor.fetchone()

while row is not None:
	print(row)
	row = cursor.fetchone()

'''
import psycopg2
from config import config
from controller.main_controller import MainController

if __name__ == '__main__':
    connection = psycopg2.connect(**config)
    main_controller = MainController(connection)
    main_controller.start()
    main_controller.close()
コード例 #13
0
ファイル: main.py プロジェクト: darkblinds/dso
def main():
    MainController().iniciar()
コード例 #14
0
 def __init__(self):
     from controller.main_controller import MainController
     self.main_controller = MainController()
     self.tasks_queue = []
コード例 #15
0
import os.path
from sys import argv, exit

from qtpy.QtWidgets import QApplication

from controller import RegisterController
from controller.main_controller import MainController
from model import init_database, Account
from utils import get_app_folder
from view import RegisterDialog
from view.main_window import MainWindow

if __name__ == '__main__':
    app = QApplication(argv)
    init_database(os.path.join(get_app_folder(), "database.sqlite"))

    accounts = Account.select()

    if not accounts:
        register_controller = RegisterController()
        register_dialog = RegisterDialog(register_controller)
        register_dialog.exec()

    controller = MainController()
    window = MainWindow(controller)

    exit(app.exec_())
コード例 #16
0
ファイル: main.py プロジェクト: jazdzyk/prace_dyplomowe
import sys

from PyQt5.Qt import QApplication

from controller.main_controller import MainController

if __name__ == '__main__':
    app = QApplication(sys.argv)
    w = MainController(
        user="******")  #"Pracownik dziekanatu")
    sys.exit(app.exec_())
コード例 #17
0
ファイル: main.py プロジェクト: jasonravagli/game-of-life
import sys

import qdarkstyle
from PyQt5.QtWidgets import QApplication

from controller.main_controller import MainController
from gui.main_window import MainWindow
from model.gol_model import GOLModel

app = QApplication(sys.argv)
# Set the dark style for PyQt5
app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))

# Create the model, GUI and controller
gol_model = GOLModel()
main_window = MainWindow(gol_model)
main_controller = MainController(app, main_window, gol_model)

main_window.show()
sys.exit(app.exec_())