예제 #1
0
    def btn_prev_clicked(self, checked):
        global prefs
        if not engine.initialize(prefs['assetdir'], self.dlg_prev.eng_view):
            print 'could not initialize dark-hammer engine'
        else:
            # get model file from the current imported model
            global main_wnd

            # before anything, do the animation import process
            self.import_clicked(True)

            model_file = str(self.edit_outfilepath.text())
            self.dlg_prev.load_props(model_file)
            self.dlg_prev.exec_()
예제 #2
0
    def btn_prev_clicked(self, checked):
        global prefs
        if not engine.initialize(prefs['assetdir'], self.dlg_prev.eng_view):
            print 'could not initialize dark-hammer engine'
        else:
            # get model file from the current imported model
            global main_wnd

            # before anything, do the animation import process
            self.import_clicked(True)

            model_file = str(self.edit_outfilepath.text())
            self.dlg_prev.load_props(model_file)
            self.dlg_prev.exec_()
예제 #3
0
파일: main.py 프로젝트: lexatnet/school
# Теперь можем несколько усложнить наше приложение
# сделаем так чтобы в коробке было несколько мячей

from engine import initialize, process_events, modify, render
from config import state

initialize(state)
while 1:
  process_events(state)
  modify(state)
  render(state)
예제 #4
0
import engine

engine = engine.Engine()
engine.initialize()
engine.crosslink()
engine.loadLevel()
engine.run()
engine.releaseLevel()
예제 #5
0
import engine
import faulthandler
import time

faulthandler.enable()

print(engine.initialize())

for i in range(engine.get_input_device_count()):
    print(engine.get_input_device_name(i))

for i in range(engine.get_output_device_count()):
    print(engine.get_output_device_name(i))

engine.set_sample_rate(44100)
engine.set_metronome_samples_per_beat(44100 / 2.0)

clip_id = engine.start_recording_clip(engine.get_default_input_device_index(),
                                      engine.get_default_output_device_index(),
                                      1024)

time.sleep(1.5)
x = engine.get_latest_recorded_samples(100000)
print(x[:50])
print(x[len(x) - 50:])
time.sleep(1.5)

engine.stop_recording_clip()
engine.save_clip(clip_id, "test.wav")
engine.delete_clip(clip_id)
new_clip_id = engine.load_clip("test.wav")
예제 #6
0
def parse_cmds(cmds):
    global prompt
    global plugin
    avail_cmds = var.get_available_cmds()
    #print(avail_cmds)
    exit_cmds = ["exit"] + var.global_cmds['exit']['Alias']
    #print(exit_cmds)
    verbose = var.global_vars['verbose']['Value']
    try:
        if cmds[0].lower() in avail_cmds:
            if cmds[0].lower() in exit_cmds:
                print_info("Exiting")
                engine.exitFlag = True
                sys.exit()
            elif cmds[0].lower() == "reset":
                if len(cmds) > 1:
                    if cmds[1].lower() == "creds":
                        creds = var.system_vars['valid-creds']
                        creds['Credentials'] = []
                        creds['Usernames'] = []
                        creds['Targets'] = []
                        if verbose:
                            print_good("Removed all credentials")
                    elif cmds[1].lower() == "offline-hosts":
                        engine.offline_hosts = []
                        print_good("Successfully reset offline hosts tracker")
                    elif cmds[1].lower() == "online-hosts":
                        engine.online_hosts = []
                        print_good("Successfully reset online hosts tracker")
                    elif cmds[1].lower() == "hosts":
                        engine.offline_hosts = []
                        engine.online_hosts = []
                        print_good("Successfully reset offline and online hosts trackers")
                else:
                    var.reset_all_vars()
                    print_info("Reset complete")
            elif cmds[0].lower() == "validate":
                try:
                    if validate.validate_options() is True:
                        print_info("Everything seems ok!")
                    else:
                        print_fail("Validation Failed!")
                except Exception as e:
                    if verbose:
                        print_fail(str(e))
                        print_fail("Error on Line:{}".format(sys.exc_info()[-1].tb_lineno))
                        print_fail("Error in Module - {}".format(MODULE_NAME))
            elif cmds[0].lower() in ['clear', 'cls']:
                clear_screen()
            elif cmds[0].lower() == "version":
                print(version)
            elif cmds[0].lower() == "about":
                print(about)
            elif cmds[0].lower() == "help" or cmds[0] == "?":
                var.get_help(cmds)
            elif cmds[0].lower() == "run" or cmds[0].lower() == "broot":
                if validate.validate_options() is True:
                    print("Starting in [3]", end="\r", flush=True)
                    sleep(1)
                    print("Starting in [2]", end="\r", flush=True)
                    sleep(1)
                    print("Starting in [1]", end="\r", flush=True)
                    sleep(1)
                    print("[*] Broot'ing...", end="\r", flush=True)
                    print("", end="\r", flush=True)
                    sleep(.5)
                    print("[*] Broot'ing...", end="\r", flush=True)
                    print("", end="\r", flush=True)
                    sleep(.5)
                    print("[*] Broot'ing...", end="\r", flush=True)
                    print("", end="\r", flush=True)
                    sleep(.5)
                    if var.check_plugin_loaded():
                        engine.initialize()
                    importlib.reload(engine)
                else:
                    print_fail("Validation Failed!")
            elif cmds[0].lower() == "back":
                plugin = "/broot"
                var.unload_plugin()
                var.wipe_loaded_plugin_info()
            elif cmds[0].lower() == "options":
                var.opts_to_table("global")
                if var.check_plugin_loaded():
                    var.opts_to_table("plugin")
            elif cmds[0].lower() == "reload":
                if cmds[1].lower() == var.get_loaded_plugin_name():
                    var.reload_loaded_plugin()
                if cmds[1].lower() == "plugins":
                    var.refresh_plugins()
                    var.show_plugins()
                    var.count_plugins()
                    var.update_cmds()
                #if cmds[1].lower() == "self":
                #    importlib.reload(engine)
                #    importlib.reload(var)
            elif cmds[0].lower() == "save":
                if cmds[1].lower() == "config":
                    save.export_sequence()
            elif cmds[0].lower() == "show":
                if cmds[1].lower() == 'config':
                    seq = save.get_current_sequence()
                    print(seq)
                elif cmds[1].lower() == 'saved-configs':
                    save.show_sequences()
                elif cmds[1].lower() == "creds":
                    var.print_successes()
                elif cmds[1].lower() == "plugins":
                    #var.refresh_plugins()
                    var.show_plugins()
                    #var.count_plugins()
                elif cmds[1].lower() == "commands":
                    var.refresh_plugins()
                    var.print_cmds(var.global_cmds)
                    #var.print_enum_dict(var.global_cmds, m="tree")
                    if var.check_plugin_loaded():
                        loaded_plugin_name = var.get_loaded_plugin_name()
                        loaded_plugin_object = var.get_loaded_plugin_object()
                        print_info("New Available Commands for '{}' Plugin:\n".format(loaded_plugin_name))
                        var.print_cmds(loaded_plugin_object.plugin_cmds)
                elif cmds[1].lower() == "sub-cmds":
                    if len(cmds) == 3:
                        sub_cmds = var.get_sub_cmds(cmds[2])
                        try:
                            for x in sub_cmds: print(x)
                        except TypeError:
                            pass
                elif cmds[1].lower() == "loaded-plugin":
                    if len(cmds) > 2:
                        if cmds[2] == "name":
                            print(var.get_loaded_plugin_name())
                        if cmds[2] == "object":
                            print(var.get_loaded_plugin_object())
                elif cmds[1].lower() == "options":
                    var.opts_to_table("global")
                    if var.check_plugin_loaded():
                        var.opts_to_table("plugin")
                else:
                    try:
                        print(var.global_vars[cmds[1].lower()]['Value'])
                    except KeyError:
                        if verbose:
                            print_info("Entry does not exist in the {}GLOBAL{} variable list".format(RED,RSTCOLORS))
                    try:
                        if var.check_plugin_loaded():
                            loaded_plugin_name = var.get_loaded_plugin_object()
                            print(loaded_plugin_name.plugin_vars[cmds[1].lower()]['Value']) 
                    except KeyError:
                        if verbose:
                            print_info("Entry does not exist in the {}PLUGIN{} variable list".format(RED,RSTCOLORS))
            elif cmds[0].lower() == "use" or cmds[0].lower() == "load":
                if cmds[1].lower() == "config":
                    try:
                        seq = save.load_sequences(cmds[2])
                        if seq is not None:
                            resp = input("[?] [m]erge/[r]eset: ")
                            if resp.lower() == "r":
                                var.reset_all_vars()
                            parse_seq(seq.rstrip())
                    except IndexError:
                        pass
                    except AttributeError:
                        pass
                else:
                    try:
                        var.unload_plugin()
                        var.wipe_loaded_plugin_info()
                        var.import_plugin(cmds[1].lower())
                        print_good("Loaded {} plugin successfully".format(cmds[1].lower()))
                        if cmds[1].lower() not in plugin:
                            plugin = "/broot/" + cmds[1].lower()
                        var.update_cmds()
                    except ModuleNotFoundError as e:
                        print_fail("Plugin not found")
                    except Exception as e:
                        if verbose:
                            print_fail(str(e))
                            print_fail("Error on Line:{}".format(sys.exc_info()[-1].tb_lineno))
                            print_fail("Error in Module - {}".format(MODULE_NAME))
                
            elif cmds[0].lower() == "set":
                if cmds[1].lower() not in var.global_cmds['set']['Sub-Cmds']:
                    print("Option '" + cmds[1] + "' does not exist")
                else:
                    try:
                        loaded_plugin = var.get_loaded_plugin_object()
                        if cmds[1].lower() in var.global_vars:
                            variable = var.global_vars[cmds[1].lower()]
                            if cmds[2].lower() == 'random':
                                handle_random_input(variable, cmds)
                            elif "file" in cmds[1].lower():
                                filename = var.file_exists(cmds[2])
                                variable['Value'] = filename
                            elif "list" in cmds[1].lower():
                                variable['Value'] = format_variable(variable)
                            else:
                                variable['Value'] = format_variable(variable, cmds[2])
                        elif cmds[1].lower() in loaded_plugin.plugin_vars:
                            variable = loaded_plugin.plugin_vars[cmds[1].lower()]
                            if hasattr(loaded_plugin, "format_variable") and callable(loaded_plugin.format_variable):
                                temp = loaded_plugin.format_variable(variable, cmds[2])
                                if temp != False:
                                    variable['Value'] = temp
                                else:
                                    if cmds[2].lower() == 'random':
                                        handle_random_input(variable, cmds)
                                    elif "file" in cmds[1].lower():
                                        filename = var.file_exists(cmds[2])
                                        variable['Value'] = filename
                                    elif "list" in cmds[1].lower():
                                        variable['Value'] = format_variable(variable)
                                    else:
                                        variable['Value'] = format_variable(variable, cmds[2])
                            else: 
                                variable['Value'] = format_variable(variable, cmds[2])
                    except IndexError:
                        pass
                    except Exception as e:
                        print_fail("Unable to set variable (is the right plugin loaded?)")
                        if verbose:
                            print_fail(str(e))
                            print_fail("Error on Line:{}".format(sys.exc_info()[-1].tb_lineno))
                            print_fail("Error in Module - {}".format(MODULE_NAME))
            elif cmds[0].lower() == "unset":
                if var.check_plugin_loaded():
                    loaded_plugin = var.get_loaded_plugin_object()
                try:
                    if cmds[1].lower() in var.global_vars:
                        variable = var.global_vars[cmds[1].lower()]
                        variable['Value'] = variable['Default']
                    elif cmds[1].lower() in loaded_plugin.plugin_vars:
                        variable = loaded_plugin.plugin_vars[cmds[1].lower()]
                        reset_value = variable['Default']
                        variable['Value'] = format_variable(variable, reset_value, mode="unset")
                except Exception as e:
                    print_fail("Unable to reset the variable (are you sure that's the right variable?)")
                    if verbose:
                            print_fail(str(e))
                            print_fail("Error on Line:{}".format(sys.exc_info()[-1].tb_lineno))
                            print_fail("Error in Module - {}".format(MODULE_NAME))
            if var.check_plugin_loaded():
                loaded_plugin = var.get_loaded_plugin_object()
                if cmds[0].lower() in loaded_plugin.plugin_cmds:
                    loaded_plugin.parse_plugin_cmds(cmds)
        else:
            print("Unrecognized Command -->", str(cmds))
    except IndexError:
        print_fail("Incomplete Command")
예제 #7
0
import engine

engine = engine.Engine()
engine.initialize()
engine.crosslink()
engine.loadLevel()
engine.run()
engine.releaseLevel()