コード例 #1
0
def main():
    print('main()')

    qmlRegisterType(CustomPaintedItem, "CustomPaintedItem", 1, 0,
                    "CustomPaintedItem")

    app = QApplication(sys.argv)
    engine = QQmlApplicationEngine()
    main_controller = MainController()
    context = engine.rootContext()
    context.setContextProperty("main", main_controller)
    script_directory = os.path.dirname(os.path.abspath(__file__))
    engine.load(os.path.join(script_directory, 'main.qml'))

    main_controller.start()

    sys.exit(app.exec_())
コード例 #2
0
def main():
    # Initialize floormap
    grid = [
        [
            -1, 0, 1, -1, -1, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1, 1,
            -1, -1, -1, 1
        ], [-1, 0, 1, 1, 1, -1, -1, -1, 0, 2, 2, 2, 2, 2, 4, 4, -1, -1, -1, 1],
        [-1, 0, 0, 0, 1, 4, 2, 2, 4, 2, 3, 3, 3, 3, 4, 2, 2, 4, 1,
         1],
        [-1, -1, -1, 0, 0, 4, -1, -1, 4, 3, 3, -1, -1, -1, 3, 3, 4, 4, 2, -1],
        [
            -1, -1, -1, -1, -1, 2, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 3, 3,
            2, 2
        ],
        [
            -1, -1, -1, -1, -1, 4, 4, 3, 3, -1, -1, -1, -1, -1, -1, -1, -1, 3,
            3, 2
        ],
        [
            -1, -1, -1, -1, -1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
            -1, 3, 2
        ],
        [
            -1, -1, -1, -1, 2, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
            -1, 3, 2
        ],
        [
            -1, -1, -1, -1, 2, 3, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
            -1, 4, 4
        ],
        [
            -1, -1, -1, -1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
            -1, 3, 2
        ],
        [
            -1, -1, -1, -1, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
            -1, 3, 2
        ],
        [
            1, 1, 1, 1, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
            3, 2
        ],
        [
            -1, -1, 0, 0, 4, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
            3, 2
        ],
        [
            0, 0, 0, -1, 2, 3, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
            3, 2
        ],
        [
            -1, -1, -1, -1, 2, 4, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
            3, 2
        ],
        [
            -1, -1, -1, -1, 1, 4, 2, 3, 3, -1, -1, -1, -1, -1, -1, -1, -1, 3,
            3, 2
        ], [-1, -1, -1, -1, 1, 0, 2, 2, 4, 3, 3, 3, 4, 3, -1, -1, 3, 3, 2, 2],
        [-1, -1, -1, 1, 1, 0, -1, 4, 4, 2, 2, 2, 4, 3, 3, 4, 3, 2, 2, -1],
        [-1, 1, 1, 1, 0, 0, -1, 1, -1, -1, -1, -1, 2, 2, 2, 4, 2, 2, -1, -1],
        [
            -1, 1, 0, 0, 0, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1,
            -1, -1
        ],
        [
            -1, 1, 0, -1, -1, -1, -1, 1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1,
            -1, -1
        ]
    ]

    floormap = np.array(grid).transpose(1, 0)

    # Set up queues for interprocess data
    cameraData = Queue()
    mainControllerData = Queue()
    simulatorData = Queue()
    travelTimeData = Queue()

    # Initialize processes
    cameraProcess = Camera(floormap, simulatorData, cameraData)
    mainControllerProcess = MainController(cameraData, mainControllerData)
    simulator = Simulator(floormap,
                          mainControllerData,
                          simulatorData,
                          travelTimeData,
                          debug=False)
    travelTime = TravelTime(travelTimeData)

    cameraProcess.start()
    mainControllerProcess.start()
    travelTime.start()

    numOfPeople = [1, 5, 10, 25, 40, 50, 100]

    simulator.run(40)
コード例 #3
0
import sys
from PyQt5.QtWidgets import QApplication
from main_controller import MainController

if __name__ == '__main__':
    a = QApplication(sys.argv)
    w = MainController()
    w.start()
    sys.exit(a.exec_())
コード例 #4
0
parser.add_argument('--torrent_file_path', type=str, required=True)
parser.add_argument('--seeder', action='store_true')
args = parser.parse_args()

if not os.path.exists(args.torrent_file_path):
    sys.exit('File torrent not exists')

torrent_file_data = parse_torrent_file(args.torrent_file_path)

info_hash = hashlib.sha1(
    json.dumps(torrent_file_data['info']).encode('utf-8')).hexdigest()
my_id = ''.join(
    random.choice(string.ascii_letters + string.digits)
    for i in range(PEER_ID_SIZE))

main_controller = MainController.start(my_id, info_hash, torrent_file_data,
                                       args.seeder)

server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_socket.bind((socket.gethostname(), 0))
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_socket.listen(5)

tracker_client = TrackerClient(my_id, info_hash,
                               server_socket.getsockname()[0],
                               server_socket.getsockname()[1],
                               torrent_file_data['tracker_ip'],
                               torrent_file_data['tracker_port'],
                               main_controller)
tracker_client.daemon = True
tracker_client.start()
コード例 #5
0
ファイル: ips_tester.py プロジェクト: priyjan5/IPS
def run_tests(configFile):
	main = MainController(configFile)
	main.start()