Ejemplo n.º 1
0
 def __initDispatchers(self):
     for x in range(self.nDispatchers):
         q = Queue()
         d = Dispatcher(q, x)
         self.clientQueue[x] = q
         self.dispatchers.append(d)
         d.start()
Ejemplo n.º 2
0
    def header(self, api):
        print '''
static HINSTANCE g_hDll = NULL;

static PROC
__getPublicProcAddress(LPCSTR lpProcName)
{
    if (!g_hDll) {
        char szDll[MAX_PATH] = {0};
        
        if (!GetSystemDirectoryA(szDll, MAX_PATH)) {
            return NULL;
        }
        
        strcat(szDll, "\\\\%s");
        
        g_hDll = LoadLibraryA(szDll);
        if (!g_hDll) {
            return NULL;
        }
    }
        
    return GetProcAddress(g_hDll, lpProcName);
}

''' % self.dllname

        dispatcher = Dispatcher()
        dispatcher.dispatch_api(api)

        Tracer.header(self, api)
Ejemplo n.º 3
0
def detail():
    if request.method == "POST":
        target, proceed = Dispatcher.create_url(request.form.get("txtbox", ""))
        print(target)
        if proceed:
            schema = Dispatcher(target).create_schema()
        else:
            schema = Dispatcher.defaults()
    else:
        schema = Dispatcher.defaults()
    return render_template("detail.html", schema=schema)
Ejemplo n.º 4
0
def main():
    """
    Parse configuration and start flask app.

    WARNING: only a single profile file is supported at this time
    """
    parser = argparse.ArgumentParser()
    parser.add_argument('--port', type=int, default=9001,
                        help="port to listen on (default=9001)")
    parser.add_argument('profiles', nargs='+',
                        help="full path to OpenC2 profile")

    args = parser.parse_args()
    
    global PROFILE
    PROFILE = Dispatcher(*args.profiles)

    app.run(port=args.port)
Ejemplo n.º 5
0
def index():
    """ parse request.args for bucket and link
    if either is present, retrieve data accordingly
    if either is present, set active attribute to True
    return schema """
    # initialize empty lists so we dont raise errors
    buckets = []
    links = []
    # get list of buckets
    buckets = database2
    # parse args
    bucket, link = parse_view_args(request.args)
    if bucket:  # retrieve child links, set bucket to active
        for each in buckets:
            if each["id"] == bucket:
                each["active"] = True
                links = each["children"]
            else:
                each["active"] = False
    else:
        for each in buckets:
            each["active"] = False
    if link:  # create preview schema, set link to active
        for each in links:
            if each["id"] == link:
                each["active"] = True
                schema = Dispatcher(each["url"]).create_schema()
            else:
                each["active"] = False
    else:
        for each in links:
            each["active"] = False
        schema = Dispatcher.defaults()
    return render_template("index.html",
                           buckets=buckets,
                           links=links,
                           schema=schema)
Ejemplo n.º 6
0
def main():

    """
    Parse configuration and start flask app.
    -
    -    WARNING: Multiple profiles are currently subtly broken in dispatch.py; 
         spreading the logic for different actions across multiple .py files should work correctly,
         but spreading the logic for the same action across multiple files will not; 
         only the target/actuator types from the last profile will be run.
    """
    global PROFILE

    parser = argparse.ArgumentParser()
    parser.add_argument('--port', type=int, default=None, help="port to listen on (default=9001)")    

    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('--conf', default=None)
    group.add_argument('--profiles', nargs='+', default=None)


    args = parser.parse_args()

    if args.profiles:

        # If a profile is specified by switches

        # Make dispatcher with loaded modules     
        PROFILE = Dispatcher(args.profiles)

        # Run the app    
        if args.port:

		app.run(port=int(args.port),host="127.0.0.1")

	else:

		app.run(port=9001,host="127.0.0.1")	

    else:

        # If a config file is specified
        if os.path.isfile(args.conf):

            app.config["yuuki"] = parse_config(args.conf)

        else:

            raise(Exception("Config file not found")) 

        # Load profiles
        profile_list = []

        for profile in app.config["yuuki"]["profiles"]:
           
            print " * Loading profile %s" % profile

            profile_list.append(app.config["yuuki"]["profiles"][profile])
        
        # Make dispatcher with loaded modules    
        PROFILE = Dispatcher(profile_list)

	if args.port:

        	# Run the app:   
       		app.run(port=int(args.port),host=app.config["yuuki"]["server"]["host"])
	else:

		# Run the app:
                app.run(port=int(app.config["yuuki"]["server"]["port"]),host=app.config["yuuki"]["server"]["host"])
Ejemplo n.º 7
0
from discord import Client
import os

from dispatch import Dispatcher

TOKEN = os.getenv('TEST_BOT_TOKEN')

class CustomClient(Client):
	async def on_ready(self):
		print(f'{self.user.name} now connected.')

	async def on_message(self, message):
		if message.author == self.user:
			return
		
		await dispatcher.dispatch(message)
		
	async def on_raw_reaction_add(self, payload):
		guild = self.get_guild(payload.guild_id)
		user = guild.get_member(payload.user_id)
		if user == self.user:
			return

		channel = self.get_channel(payload.channel_id)
		msg = await channel.fetch_message(payload.message_id)

client = CustomClient()
dispatcher = Dispatcher(client)

client.run(TOKEN)
Ejemplo n.º 8
0
    print('}')


if __name__ == '__main__':
    # glClientSideBufferData is a fake api to update client-side memory
    glesapi.delFunctionByName("glClientSideBufferData")
    glesapi.delFunctionByName("glClientSideBufferSubData")
    glesapi.delFunctionByName("glCreateClientSideBuffer")
    glesapi.delFunctionByName("glDeleteClientSideBuffer")
    glesapi.delFunctionByName("glCopyClientSideBuffer")
    glesapi.delFunctionByName("glPatchClientSideBuffer")
    # glGenGraphicBuffer_ARM, glGraphicBufferData_ARM and glDeleteGraphicBuffer are fake APIs to use GraphicBuffer on Android or to use DMA buffer on Linux
    glesapi.delFunctionByName("glGenGraphicBuffer_ARM")
    glesapi.delFunctionByName("glGraphicBufferData_ARM")
    glesapi.delFunctionByName("glDeleteGraphicBuffer_ARM")
    dispatcher = Dispatcher()

    #############################################################
    sys.stdout = open('eglproc_auto.hpp', 'w')
    print('// Generated by', sys.argv[0])
    print('#ifndef _DISPATCH_EGLPROC_HPP_')
    print('#define _DISPATCH_EGLPROC_HPP_')
    print()
    print('#include "eglimports.hpp"')
    print('#include "common/os.hpp"')
    print()
    print('#ifndef GLES_CALLCONVENTION')
    print('#define GLES_CALLCONVENTION')
    print('#endif')
    print()
    print('void * _getProcAddress(const char *procName);')
Ejemplo n.º 9
0
def setup_dispatch(app):
    dispatcher = Dispatcher()
    app['dispatcher'] = dispatcher
    app.on_startup.append(start_dispatcher)
Ejemplo n.º 10
0
    col = []
    for x in range(0, config.world_size[0]):
        col.append( Grass(x, y, vp) )
    vp.map_layer.append(col)

for y in range(0, config.world_size[1]):
    col = []
    for x in range(0, config.world_size[0]):
        col.append( None )
    vp.item_layer.append(col)

# generate item layer
generate_items_layer(vp)

#generate units
dispatcher = Dispatcher(vp)
vp.hud.dispatcher = dispatcher
#dispatcher.tasks.append( Task( GenericTarget( 20, 20) ) )
#dispatcher.tasks.append( Task( GenericTarget( 0, 20) ) )
#dispatcher.tasks.append( Task( GenericTarget( 20, 0) ) )
#dispatcher.tasks.append( Task( GenericTarget( 15, 7) ) )
#dispatcher.tasks.append( Task( GenericTarget( 50, 50) ) )
Unit.load_images()
num_units = 5

unit_count = 0
for y in range(0, config.world_size[1]):
    for x in range(0, config.world_size[0]):
        if vp.item_layer[y][x] == None:
            unit = Unit(x, y, vp, dispatcher)
            vp.unit_layer.append( unit )
Ejemplo n.º 11
0
        type='string',
        dest='nametype',
        default='vid',
        help='how to name the video file. vid and title. default is vid. ')
    parser.add_option('-f',
                      action='store_true',
                      dest='force',
                      default=False,
                      help='overwrite the existing file.default is False.')
    parser.add_option(
        '-m',
        action='store_true',
        dest='makejson',
        default=False,
        help='if create json file that describe the video. default is False.')
    parser.add_option('-e',
                      '--ext',
                      action='store',
                      type='string',
                      dest='ext',
                      default='mp4',
                      help='output video extended name. default is mp4.')
    options, args = parser.parse_args()
    url = options.__dict__.get('url')
    c = Condition(**options.__dict__)
    if url is None or len(url) == 0:
        print('error: video url is None! exit...')
        sys.exit(0)

    Dispatcher(c)