示例#1
0
def reset_traffic_job():
    def run_next():
        now = datetime.now()
        next_day = now.date() + timedelta(days=1)
        next_time = datetime.combine(next_day, datetime.min.time())
        Timer((next_time - now).seconds + 5, reset_traffic_job).start()

    now = datetime.now()
    year = now.year
    month = now.month
    day = now.day
    end_day = calendar.monthrange(int(year), int(month))[1]
    reset_day = config.get_reset_traffic_day()
    if end_day < reset_day:
        reset_day = end_day
    if day == reset_day:
        if config.is_traffic_reset():
            run_next()
            return
        Inbound.query.update({"up": 0, "down": 0})
        db.session.commit()
        config.update_setting_by_key("is_traffic_reset", 1)
    else:
        config.update_setting_by_key("is_traffic_reset", 0)
    run_next()
示例#2
0
文件: v2-ui.py 项目: zysr/v2-ui
    if len(sys.argv) > 1:
        if sys.argv[1] == 'resetconfig':
            config.reset_config()
            print('All panel settings have been reset to default values, now please restart the panel')
        elif sys.argv[1] == 'resetuser':
            from base.models import User
            from init import db
            User.query.update({'username': '******', 'password': '******'})
            db.session.commit()
            print('The username and password have been reset to admin, please restart the panel now')
        elif sys.argv[1] == 'setport':
            if len(sys.argv) > 2:
                port = sys.argv[2]
            else:
                port = 65432
            config.update_setting_by_key('port', port)
            print('Set port to ' + port + ' successfully')
        else:
            print('Invalid command')
            print('resetconfig: Reset all panel settings to default values')
            print('resetuser: Reset username and password to \'admin\'')
            print('setport [number]: Set web port to [number], default is 65432')
    else:
        init_windows()
        logging_init()
        try:
            main()
        except BaseException as e:
            logging.error(str(e))
            raise e
示例#3
0
if __name__ == '__main__':
    if len(sys.argv) > 1:
        if sys.argv[1] == 'resetconfig':
            config.reset_config()
            print(
                'All panel settings have been reset to default values, now please restart the panel'
            )
        elif sys.argv[1] == 'resetuser':
            from base.models import User
            from init import db
            User.query.update({'username': '******', 'password': '******'})
            db.session.commit()
            print(
                'The username and password have been reset to admin, please restart the panel now'
            )
        elif sys.argv[1] == 'setport':
            config.update_setting_by_key('port', sys.argv[2])
            print('Set port to ' + sys.argv[2] + ' successfully')
        else:
            print('Invalid command')
            print('resetconfig: Reset all panel settings to default values')
            print('resetuser: Reset username and password to \'admin\'')
            print('setport: Set port')
    else:
        logging_init()
        try:
            main()
        except BaseException as e:
            logging.error(str(e))
            raise e
示例#4
0
        elif sys.argv[1] == "resetuser":
            from base.models import User
            from init import db

            User.query.filter_by(id=1).update(
                {"username": "******", "password": "******", "is_admin": True}
            )
            db.session.commit()
            print(
                "The username and password have been reset to admin, please restart the panel now."
            )
        elif sys.argv[1] == "setport":
            if len(sys.argv) > 2:
                port = sys.argv[2]
            else:
                port = 65432
            config.update_setting_by_key("port", port)
            print("Set port to " + port + " successfully.")
        else:
            print("Invalid command.")
            print("resetconfig: Reset all panel settings to default values")
            print("resetuser: Reset username and password to 'admin'")
            print("setport [number]: Set web port to [number], default is 65432")
        os._exit(0)
    else:
        try:
            main()
        except BaseException as e:
            logging.error(str(e))
            raise e