コード例 #1
0
def signup():
    have_error = False
    username = raw_input('username: '******'password: '******'verify: ')
    email = raw_input('email: ')

    if not valid_username(username):
        have_error = True

    if not valid_password(password):
        have_error = True

    elif password != verify:
        have_error = True

    if not valid_email(email):
        have_error = True

    if have_error:
        print('signup.html')

    else:
        user_create = usermanager.UserManager()
        user_create.create_user(username, password, email)
        print('/welcome?username=' + username)
コード例 #2
0
def read():
    username = raw_input('username: '******'/error')
コード例 #3
0
def remove():
    username = raw_input('remove username:'******'/success')
    else:
        print('/error')
コード例 #4
0
ファイル: yah3c.py プロジェクト: ZhanruiLiang/YaH3C
def main():
    # parse the options from argv
    ps, opts = parse_options()

    if 'h' in opts or 'help' in opts:
        ps.print_help()
        return

    # check for root privilege
    if not (os.getuid() == 0):
        print('亲,要加sudo!')
        exit(-1)

    if not is_single():
        exit(1)

    # collect login info
    um = usermanager.UserManager()
    login_info = []
    if um.get_user_number() == 0:
        choice = raw_input(
            'No user conf file found, creat a new one?\n<Y/N>: ')
        if choice in ('y', 'Y'):
            um.create_user(prompt_user_info())

    users_info = um.get_users_info()
    if opts.a:
        try:
            login_info = prompt_user_info()
            um.create_user(login_info)
        except ConfigParser.DuplicateSectionError:
            print 'user already exist!'
    elif opts.c:
        for i, u in enumerate(users_info):
            print i, u

        while True:
            try:
                choice = int(raw_input('Your choice: '))
                if choice >= len(users_info):
                    raise ValueError
            except ValueError:
                print 'Please input a valid number!'
            else:
                break

        login_info = um.get_user_info(choice)
    else:
        login_info = um.get_user_info(0)

    # begin authorize
    yah3c = eapauth.EAPAuth(login_info)
    yah3c.serve_forever()
コード例 #5
0
    def run(self):
        try:
            self._database = database.bot.BotInterface(self._loop, self._config['ddmbot'])
            self._stream = streamserver.StreamServer(self)
            self._player = player.Player(self)
            self._users = usermanager.UserManager(self)
        except:
            self._loop.run_until_complete(self._client.close())
            self._loop.close()
            raise

        try:
            self._loop.run_until_complete(self._player.init())
            self._loop.run_until_complete(self._stream.init())
            self._loop.run_until_complete(self._client.login(self._config['discord']['token']))

            self._bot_task = asyncio.gather(self._database.task_credit_renew(), self._users.task_check_timeouts(),
                                            self._player.task_player_fsm(), self._client.connect(), loop=self._loop)

            try:
                self._loop.run_until_complete(self._bot_task)
            except asyncio.CancelledError:
                pass
            finally:
                self._bot_task.cancel()
                with suppress(asyncio.CancelledError):
                    self._loop.run_until_complete(self._bot_task)

            # determine if we wanna shut down the bot instead of restarting it
            if not self._restart:
                raise KeyboardInterrupt()

        finally:
            self._loop.run_until_complete(self._client.logout())
            self._loop.run_until_complete(self._player.cleanup())
            self._loop.run_until_complete(self._stream.cleanup())

            pending = asyncio.Task.all_tasks()
            for task in pending:
                task.cancel()
                with suppress(asyncio.CancelledError, asyncio.TimeoutError, InvalidState, OSError):
                    self._loop.run_until_complete(task)

            self._loop.close()
コード例 #6
0
ファイル: yah3c.py プロジェクト: zbhknight/pscripts
def main():
    # check for root privilege
    if not (os.getuid() == 0):
        print('亲,要加sudo!')
        exit(-1)

    um = usermanager.UserManager()
    login_info = []
    if (um.get_user_number() == 0):
        choice = raw_input(
            'No user conf file found, creat a new one?\n<Y/N>: ')
        if choice == 'y' or choice == 'Y':
            login_info = prompt_user_info()
            um.create_user(login_info)
        else:
            exit(-1)
    else:
        users_info = um.get_users_info()

        print '0. add a new user'
        for i in range(len(users_info)):
            print i + 1, users_info[i]

        while True:
            try:
                choice = int(raw_input('Your choice: '))
            except ValueError:
                print 'Please input a valid number!'
            else:
                break
        if (choice == 0):
            try:
                login_info = prompt_user_info()
                um.create_user(login_info)
            except ConfigParser.DuplicateSectionError:
                print 'user already exist!'
        else:
            login_info = um.get_user_info(choice - 1)

    yah3c = eapauth.EAPAuth(login_info)
    yah3c.serve_forever()