Example #1
0
 def __init__(self):
     """
     Instantiate the plugin and all its modules.
     """
     self._core = Core(self)
     self._interface = Interface(self)
     self._network = Network(self)
Example #2
0
    def __init__(self, parent: QtWidgets.QWidget=None):
        super().__init__(parent)
        self.actions = {}
        self.menus = {}
        self.edit_lines = {}
        self.buttons = {}
        self.layouts = {}
        self.widgets = {}

        self.core = Core()

        self.create_edit_lines()
        self.create_buttons()
        self.create_actions()

        self.create_menus()
        self.create_layouts()
        self.create_widgets()
        self.create_toolbars()

        self.setCentralWidget(self.widgets['central_widget'])

        self.connect_widgets_and_layouts()
        self.statusBar()
        self.connect_signals_to_slots()
Example #3
0
def main():
    core = Core()
    core.cb.set_cb_regstate(regstate_cb)
    core.start()

    print "Registered at",
    print "sip:", core.transport.info().host, " port", core.transport.info(
    ).port

    while True:
        print "Menu: m=make call, h=hangup call, a=answer call, q=quit"
        input = sys.stdin.readline().rstrip("\r\n")
        if input == "m":
            print "Destination URI:",
            input = sys.stdin.readline().rstrip("\r\n")
            if input == "":
                continue
            core.make_call(input)
            continue

        elif input == "h":
            core.hangup_call(core.calls.current_call)
            continue

        elif input == "a":
            core.answer_call(core.calls.current_call)
            continue

        elif input == "q":
            break

    core.stop()
Example #4
0
 def setUp(self):
     self.core = Core()
     self.pjvalue = 5
     self.pjmod = 2
     self.vsvalue = 4
     self.vsmod = 1
     self.dificultad = 10
     self.delim = '\n============================='
Example #5
0
    def test_subscribing_non_class(self):
        class BadSubscriber(BaseModule):
            def boot(self):
                self.subscribe(lambda: None, types='MyEvent')

        ai = Core()
        module = BadSubscriber()
        ai.add_module(module)
        self.assertRaises(ModuleSubscribedToNonClassError, lambda: ai.boot())
Example #6
0
def test():
    core = Core()
    # no_array = ['34XXX', '66XXX', '78XXX', '87XXX', '57XXX', '93XXX', '97XXX', '67XXX', '12XXX', '74XXX', '08XXX', '69XXX', '56XXX', '18XXX', '91XXX', '27XXX', '01XXX', '72XXX', '52XXX', '41XXX', '10XXX', '28XXX', '31XXX', '95XXX', '68XXX', '39XXX', '33XXX', '24XXX', '90XXX', '16XXX', '20XXX', '64XXX', '30XXX', '94XXX', '07XXX', '76XXX', '29XXX', '58XXX', '23XXX', '83XXX', '19XXX', '11XXX', '61XXX', '46XXX', '65XXX', '51XXX', '63XXX', '17XXX', '89XXX', '79XXX']
    # for i in range(100):
    # 	period = 258000 + i * 120
    # 	core.get_regression_cycle_v2(period, 50, no_array)
    # core.get_regression_cycle(50000)
    # core.get_regression_cycle(10000, 10000, 50000, 20)
    core.get_max_drop_regression(270000, 50)
Example #7
0
def main():
	url = ''
	t = 30
	r = 10
	c = ''
	r = False
	d = 5
	try:
		opt,argv = getopt.getopt(sys.argv[1:],'hu:t:',['help','url'])
		if opt == []:
			print '\t[!] Please input the parameter.'
			usage()
			exit()
	except getopt.GetoptError as e:
		print e
		usage()
		exit(0)
	for o,v in opt:
		if o in ('-h','--help'):
			usage()
			exit(0)
		if o in ('-u','--url'):
			if v == '':
				print 'url can\'t be null'
				exit(0)
			url.strip()
			if v[0:7] != 'http://':
				v = 'http://' + v
			if v[-1] != '/':
				v += '/'
			url = v
		if o in ('-t','--thread_num'):
			if v.isdigit():
				thread_num = int(v)
			else :
			 	print 'Thread_num is NOT a digit!'
			 	exit(0)	
		if o in ('-c','--cookie'):
			c = serializeCookie(v)
		if o in ('-r','--retry'):
			if v.isdigit():
				retry = int(v)
			else :
			 	print 'retry times is NOT a digit!'
			 	exit(0)
		# if o in ('-R','--recursive'):
		# 	r = True
		# 	if o in ('-d','--depth') and v.isdigit():
				
	print '[*] Start'
	sTime = time.time()
	# print str(sTime)
	a = Core(url,t,c,r)
	a.createThread()
	a.getRes()
	print '[*] Used ' + str(time.time()-sTime) + ' s'
Example #8
0
    def test_module_receives_all_events(self):
        ai = Core()
        module = AllEventsModule()
        ai.add_module(module)

        ai.boot()

        ai.publish(EventTypeA(content="a"))
        ai.publish(EventTypeB(content="b"))

        self.assertEqual(['a', 'b'], module.received_events)
Example #9
0
    def __init__(self, ui):
        self.form = ui
        # dimanakah letak form.ui????? apa hubungannya????

        self.core = Core()
        self.holding = False  #flag
        self.core.cb.set_cb_callstate(self.call_state_cb)
        self.core.cb.set_cb_regstate(self.regstate_cb)
        self.core.cb.set_cb_incoming_call(self.incoming_call_cb)

        self.core.start()
Example #10
0
    def test_handler_without_type_hint(self):
        class ModuleWithMultipleTypes(BaseModule):
            def boot(self) -> None:
                self.subscribe(self.handle, types=[EventTypeA, EventTypeB])

            def handle(self, event):
                pass

        ai = Core()
        ai.add_module(ModuleWithMultipleTypes())
        ai.boot()
def startup(verbosity, port, interface):
    logging.basicConfig(
        format='[%(asctime)s][%(levelname)s]%(name)s: %(message)s',
        datefmt='%Y/%m/%d-%H:%M:%S',
        level=logging.INFO if verbosity else logging.WARNING)
    global house_core
    house_core = Core()
    if sender.getServerVersion() >= 400:
        exit(-1)
    # if sender.registerSubscriptions() >= 400:
    #     exit(-1)
    app.run(host=interface, port=port)
Example #12
0
    def __init__(self):
        cmd.Cmd.__init__(self)
        self.core = Core()
        self.core.list()

        self.intro = "\nDecision Support System Logger: For information type help or ? \n"
        self.prompt = ">> "
        self.completekey = 'tab'

        self._hist = []
        self._locals = []
        self._globals = []
Example #13
0
    def test_handler_type_matches_subscribe(self):
        class ModuleWithTypeMismatch(BaseModule):
            def boot(self) -> None:
                self.subscribe(self.handle, types=EventTypeA)

            def handle(self, event: EventTypeB):
                pass

        ai = Core()
        ai.add_module(ModuleWithTypeMismatch())

        self.assertRaises(ModuleError, lambda: ai.boot())
Example #14
0
    def test_handler_arguments(self):
        class FooModule(BaseModule):
            def boot(self):
                self.subscribe(self.handle)

            def handle(self, message):
                pass

        ai = Core()
        ai.add_module(FooModule())

        self.assertRaises(ModuleError, lambda: ai.boot())
Example #15
0
    def test_publishing_non_class(self):
        class BadPublisher(BaseModule):
            def boot(self):
                pass

        ai = Core()
        module = BadPublisher()
        ai.add_module(module)

        ai.boot()

        self.assertRaises(ModulePublishedBadEventError,
                          lambda: module.publish("not an event"))
Example #16
0
def main() -> int:
    """
    Define the project's mainline execution.

    Creates and interacts with the command line argument parser, `argparse`,
    in addition to setting the debugging standard project-wide, and initiating
    file processing with the `Core` module.

    This method exists largely as a pseudo-manager for keeping track of program
    flow and high-level return codes.
    """
    # Define a program for the argument argparser
    argparser = argparse.ArgumentParser(description="C file parser for unique \
        strings and their associated functions")

    # Verbosity is a boolean flag rather than the traditional level
    argparser.add_argument("-v",
                           "--verbose",
                           help="Set verbosity/\
        debug level",
                           action="store_true")

    # A user may specify n files as positional arguments
    argparser.add_argument("files", type=argparse.FileType("r"), nargs="+")

    # Grab the arguments from the command line
    args = argparser.parse_args()

    # Configures the hierarchical (root-level) logger instance
    # TODO: Granularity beyond ON/OFF may follow in future releases
    if args.verbose:
        logging.basicConfig(level=logging.DEBUG)

    # Create an instance of `Core`, which is responsible for managing
    # high level functionality and program flow
    mngr = Core()

    # Double check that the files specified on the command line are
    # in the proper mode and exist at the correct location
    Verifier.check_parsable(args.files)

    # Process each file, appending unique func:str pairs as found
    mngr.process_files(args.files)

    # Ultimately produce a final dictionary and convert to JSON
    mngr.generate_bundle()

    # Drop the JSON bundle to disk under the out/ directory
    mngr.export()

    return 0
Example #17
0
    def test_module_should_not_subscribe_after_boot(self):
        class ModuleSubscribingAfterBoot(BaseModule):
            def boot(self) -> None:
                self.subscribe(self.handle, EventTypeA)

            def handle(self, event: EventTypeA) -> None:
                self.subscribe(lambda event: None, EventTypeB)

        ai = Core()
        ai.add_module(ModuleSubscribingAfterBoot())
        ai.boot()

        self.assertRaises(ModuleSubscribedAfterBoot,
                          lambda: ai.publish(EventTypeA('foobar')))
Example #18
0
 def __init__(self, app):
     QMainWindow.__init__(self)
     self.app = app
     self.core = Core()
     self.assets: Assets = Assets()
     self.last_login: str = 'never'
     self.login_repeater = Repeater()
     self.tray_icon = SystemTrayIcon(parent=self,
                                     assets=self.assets,
                                     profile_list=self.core.config.list_groups())
     self.log_dialog = LogDialog(self)
     self.config_dialog = ConfigDialog(self)
     self.set_key_dialog = SetKeyDialog(self)
     self.rotate_key_dialog = RotateKeyDialog(self)
     self.tray_icon.show()
Example #19
0
    def test_add_task(self):
        e = []

        class ModuleWithTask(BaseModule):
            def boot(self) -> None:
                self.add_task(self.sleep())

            async def sleep(self) -> None:
                await asyncio.sleep(0.001)
                e.append('done')

        ai = Core()
        ai.add_module(ModuleWithTask())
        ai.boot()

        self.assertEqual(['done'], e)
Example #20
0
    def test_handle_metadata(self):
        received_ids = []

        class MetadataModule(BaseModule):
            def boot(self):
                self.subscribe(self.handler)

            def handler(self, event: BaseEvent, metadata: Metadata):
                received_ids.append(metadata.id)

        ai = Core(metadata_provider=lambda: Metadata(id=test_uuid))
        ai.add_module(MetadataModule())
        ai.boot()

        ai.publish(TestEvent('hello'))

        self.assertEqual([test_uuid], received_ids)
Example #21
0
    def test_metadata_id_is_same_for_all_handlers(self):
        received_ids = []

        class MetadataModule(BaseModule):
            def boot(self):
                self.subscribe(
                    lambda metadata: received_ids.append(metadata.id))
                self.subscribe(
                    lambda metadata: received_ids.append(metadata.id))

        ai = Core()
        ai.add_module(MetadataModule())
        ai.boot()

        ai.publish(TestEvent('hello'))

        self.assertEqual(2, len(received_ids))
        self.assertEqual(received_ids[0], received_ids[1])
def main():
    banner()
    parser = argparse.ArgumentParser(description='UserFinder v1.0.1')
    parser.add_argument('-u',
                        '--url',
                        type=str,
                        help='Crawl specific url',
                        default=None)
    parser.add_argument('-n',
                        '--name',
                        type=str,
                        help='Crawl specific name',
                        default=None,
                        required=True)
    parser.add_argument('-v', "--verbose", action='store_true', default=False)
    args = parser.parse_args()

    c = Core(name=args.name, url=args.url, verbose=args.verbose)
    c.run()
Example #23
0
    def trigger(self, evaluation_type):
        for nc in self.network_configurations:

            for spec in self.background_specs:

                nc.setup_network_graph(mininet_setup_gap=1, synthesis_setup_gap=1)
                background = self.configure(nc, self.run_time, self.base_dir, spec, evaluation_type)

                exp = Core(self.run_time,
                           nc,
                           self.script_dir,
                           self.base_dir,
                           self.replay_pcaps_dir,
                           self.base_dir + "/logs/" + str(nc.project_name) + "_" + evaluation_type + "_" + str(nc.link_latency) + "_" + str(spec),
                           background[0],
                           background[1],
                           background[2])

                exp.start_project()
Example #24
0
    def setUp(self):
        # Bind model classes to test db. Since we have a complete list of
        # all models, we do not need to recursively bind dependencies.
        test_db.bind(MODELS, bind_refs=False, bind_backrefs=False)

        test_db.connect()
        test_db.create_tables(MODELS)

        # create primitives
        for raza in RAZAS:
            Raza.create(nombre=raza[1])

        for modtype in MOD_TYPE:
            Mod.create(nombre=modtype[1])

        for dif in DIFICULTADES:
            Dificultad.create(valor=dif[0], texto=dif[1])

        self.partida = Partida.create(nombre="Partida test")
        self.core = Core()
Example #25
0
    def test_output_expression_result(self):
        class TestHelperBot(BaseModule):
            events: List[BaseEvent]

            def boot(self) -> None:
                self.events = []
                self.subscribe(lambda event: self.events.append(event))

        helper = TestHelperBot()
        bot = MathBot()

        ai = Core()
        ai.add_module(bot)
        ai.add_module(helper)
        ai.boot()
        ai.publish(TextInput('10+2'))

        self.assertIn(MathParsed(Addition(Constant(10), Constant(2))),
                      helper.events)
        self.assertIn(TextOutput('The result is: 12.0'), helper.events)
Example #26
0
    def test_module_receives_only_events_it_subscribed_to(self):
        class AEventsModule(BaseModule):
            received_events = []

            def boot(self):
                self.subscribe(self.handle_a, types=EventTypeA)

            def handle_a(self, event: EventTypeA):
                self.received_events.append(event.content)

        ai = Core()
        foobar = AEventsModule()
        ai.add_module(foobar)

        ai.boot()

        ai.publish(EventTypeA(content="a"))
        ai.publish(EventTypeB(content="b"))

        self.assertEqual(['a'], foobar.received_events)
    def setUp(self):
        self.settings = Settings.load_config('../conf.json')

        # Centrifuge uses it's own internal process.
        # During running the tests this process prevents correct server shutdown and socket does not returns port.
        # To prevent it - centrifuge should be simply disabled.
        # (it is not used in this tests)
        self.settings.use_centrifuge = False

        self.core = Core(self.settings)

        def run():
            # It is necessary to seed random in forked process,
            # otherwise - Crypto would throw an error.
            Random.atfork()

            self.core.run()

        self.process = Process(target=run)
        self.process.start()

        # Wait until server would be stopped.
        sleep(0.5)
Example #28
0
from core.core import Core

core = Core()
#getUserSuscribedCommunities
#print core.UserOperation("getByIdUser", {"_id":"5891cced481f3416aa786783"})
#print core.UserOperation("getUserSuscribedCommunities", {"_id":"5891cced481f3416aa786783"})
#print core.CommunityOperation("getUserSuscribedCommunities", {"_id":"5891cced481f3416aa786783"})
#58948f16481f342f73d3d0ab

#print core.UserOperation("suscribeUser2Community", {"id_user":"******","id_community":"58936e7c481f3408dea712ea"})
#print core.UserOperation("unsuscribeUser2Community", {"id_user":"******","id_community":"58945f60481f340f226a9ba1"})

#print core.UserOperation("unsuscribeUser2Community", {"id_user":"******","id_community":"58948f16481f342f73d3d0ab"})
#print core.UserOperation("getByIdUser", {"_id":"5891cd34481f3416aa786785"})
#print core.UserOperation("deleteCommunityUnsuscribe", {"field":"communities_suscribed","_id":"58936e7c481f3408dea712ea"})


#589329df481f341a9db95828
#print core.UserOperation("suscribeUser2Community", {"id_user":"******","id_community":"5893723f481f340b515646a7"})
#print core.UserOperation("suscribeUser2Community", {"id_user":"******","id_community":"5893723f481f340b515646a7"})
#print core.UserOperation("suscribeUser2Community", {"id_user":"******","id_community":"5893723f481f340b515646a7"})
#result = core.PostOperation("getPostByCommunityId", {"community_id" : '5898b236481f3449bb923c94'})
result = core.PostOperation("getCommunityPosts", {"community_id" : '5898b236481f3449bb923c94'})
#result = core.UserOperation("getAllUsersFiltered", {'query':{}, 'filter':{'name':1, 'nick':1}})
print result
#print type(result)
#print result
Example #29
0
 def __init__(self):
     self._core = Core()
     self._response = self._core.response
Example #30
0
 def test_ai_must_be_booted_before_publishing(self):
     ai = Core()
     self.assertRaises(CoreNotBootedError,
                       lambda: ai.publish(EventTypeA(content="a")))