Exemplo n.º 1
0
    def start(self):

        ## register handlers
        modules.init(self.client, self.sources)

        ## register background events

        # Start
        self.client.start(bot_token=c.BOT_TOKEN)
        asyncio.get_event_loop().run_forever()
Exemplo n.º 2
0
    def start(self):

        ## register handlers
        modules.init(self.client, self.img_cache, self.global_bucket,
                     self.sales_obj)

        ## register background events
        asyncio.ensure_future(discounts_job(self.client, self.sales_obj))

        # Start
        self.client.start(bot_token=c.TOKEN)

        asyncio.ensure_future(self.cache_imgs())

        self.client.run_until_disconnected()
Exemplo n.º 3
0
def server_control(config, daemon_cmd):
    start_cmd = "start"
    stop_cmd = "stop"
    restart_cmd = "restart"

    wbconfig = config["wordbase"]

    pidfile = wbconfig.get("pidfile", "/var/run/" + PROGRAM_NAME + ".pid")
    wbdaemon = WBDaemon(PROGRAM_NAME, pidfile, start_server)
    control_func = None

    if daemon_cmd in (None, start_cmd, restart_cmd):
        random.seed()

        smconfig = config["srvmon"]
        util.srvmon.configure(smconfig)

        modules.init(config)

        dconfig = config["dict"]
        match.configure(dconfig)
        core.configure(dconfig)

        wbdaemon.run_args = (wbconfig, modules.mp())

        if daemon_cmd == start_cmd:
            control_func = wbdaemon.start
        elif daemon_cmd == restart_cmd:
            control_func = wbdaemon.restart
        elif daemon_cmd is None:
            control_func = wbdaemon.run
        else:
            assert False, "unhandled command"

        log_init = True
    elif daemon_cmd == stop_cmd:
        control_func = wbdaemon.stop
        log_init = False
    else:
        print('command "{}" not recognized'.format(daemon_cmd), file=sys.stderr)
        print_help_hint()
        sys.exit(2)

    if log_init:
        logger.debug("initialized")

    control_func()
Exemplo n.º 4
0
def main(argv):
	opts, args = getopt.getopt(argv, "v:c", [ "debug", "config=" ])
	print(opts)

	debug = False
	configFile = None

	dn = os.path.dirname(__file__)
	if dn is not "":
		os.chdir(dn)
	del dn

	for arg,val in opts:
		if arg == "--debug" or arg == "-v":
			debug = True
		elif arg == "--config" or arg == "-c":
			configFile = val

	if configFile is None:
		configFile = "data/config-debug.cfg" if debug else "data/config.cfg"

	if not os.path.isfile(configFile):
		if os.path.isfile("data/config.cfg"):
			logging.warn("Config file %s missing, reverting to default" % configFile)
			configFile = "data/config.cfg"
		else:
			logging.error("""We are missing a config file, please look at the example.cfg for help on making a new config, and name it config.cfg or pass a config file using --config

The config file should go in the data directory""")
			return
	

	logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
	#logging.config.fileConfig("logging.cfg")



	config = Config();

	logging.info("Reading config file: %s" % configFile)
	try:
		config.read(configFile)
	except Exception as e:
		logging.error("Error reading config file: %s" % e)
		return

	if debug:
		logging.info("Debug mode activated")

	basic = config.get_section("Basic")

	modules.cfg_basic = basic
	modules.config = config

	modules.init()

	schongos = {}

	for i in basic.getlist("networks"):
		net = config.get_section("Network/%s" % i)
		sch = SchongoClient(i, net)
		"""
			server=net.get("server"),
			port=net.getint("port"),
			)icks=net.getlist("nicks"),
			ident=net.get("ident"),
			realname=net.get("real name"),
			network=i,
			channels=net.getlist("channels")
		)"""
		sch.connect()
		sch.start()
		schongos[i] = sch
	
	modules.connections = schongos

	return schongos
Exemplo n.º 5
0
from modules import time, sys, Fore, init, classes, datetime

init(autoreset=True)

global counter
counter = 0


def hangman_user_main():
    print(Fore.BLUE + "Welcome to Hangman (User Panel)")
    user_name = input(Fore.BLUE + "Please enter a Username: "******"session.txt", user_name)
    wait_for_admin()
    wait_for_secret_word()


def wait_for_admin():
    if session_user.state() == 0:
        session_user.start_user()
    else:
        time.sleep(1)
        wait_for_admin()


def wait_for_secret_word():
    session_user.open_file("r")
    import_session = session_user.file.readline().split(',')
    while len(import_session) >= 3:
        session_user.close_file()
        session_user.open_file("r")
Exemplo n.º 6
0
# import esky
# import py2app
import locale, modules

import globalvars

# Get system language

modules.init()


def adjust_f(sender):
    if adjust_f.huh:
        sender.add('$')
        sender.add('%')
        sender['zzz'] = 'zzz'
        sender['separator'] = separator
        sender['ppp'] = MenuItem('ppp')
    else:
        del sender['$']
        del sender['%']
        del sender['separator']
        del sender['ppp']
    adjust_f.huh = not adjust_f.huh


adjust_f.huh = True


def print_f(_):
    print(f)
Exemplo n.º 7
0
def main(argv):
    opts, args = getopt.getopt(argv, "v:c", ["debug", "config="])
    print(opts)

    debug = False
    configFile = None

    dn = os.path.dirname(__file__)
    if dn is not "":
        os.chdir(dn)
    del dn

    for arg, val in opts:
        if arg == "--debug" or arg == "-v":
            debug = True
        elif arg == "--config" or arg == "-c":
            configFile = val

    if configFile is None:
        configFile = "data/config-debug.cfg" if debug else "data/config.cfg"

    if not os.path.isfile(configFile):
        if os.path.isfile("data/config.cfg"):
            logging.warn("Config file %s missing, reverting to default" %
                         configFile)
            configFile = "data/config.cfg"
        else:
            logging.error(
                """We are missing a config file, please look at the example.cfg for help on making a new config, and name it config.cfg or pass a config file using --config

The config file should go in the data directory""")
            return

    logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
    #logging.config.fileConfig("logging.cfg")

    config = Config()

    logging.info("Reading config file: %s" % configFile)
    try:
        config.read(configFile)
    except Exception as e:
        logging.error("Error reading config file: %s" % e)
        return

    if debug:
        logging.info("Debug mode activated")

    basic = config.get_section("Basic")

    modules.cfg_basic = basic
    modules.config = config

    modules.init()

    schongos = {}

    for i in basic.getlist("networks"):
        net = config.get_section("Network/%s" % i)
        sch = SchongoClient(i, net)
        """
			server=net.get("server"),
			port=net.getint("port"),
			nicks=net.getlist("nicks"),
			ident=net.get("ident"),
			realname=net.get("real name"),
			network=i,
			channels=net.getlist("channels")
		)"""
        sch.connect()
        sch.start()
        schongos[i] = sch

    modules.connections = schongos

    return schongos