Пример #1
0
    def do_post(self, line):
        """
        Execute post-processor.

        Available post-processors:

            {post}

        For more information about a particular post processor (in this case
        `save`)

            > help post save

        """
        try:
            changed = post.run(self.interp, line)
        except:
            show_traceback()
            readline.write_history_file(self.hist)
        else:
            self._changed(changed)
Пример #2
0
Файл: repl.py Проект: nwf/dyna
    def do_post(self, line):
        """
        Execute post-processor.

        Available post-processors:

            {post}

        For more information about a particular post processor (in this case
        `save`)

            > help post save

        """
        try:
            changed = post.run(self.interp, line)
        except:
            show_traceback()
            readline.write_history_file(self.hist)
        else:
            self._changed(changed)
Пример #3
0
    if info[i].get("enable") == 'true':
        name = info[i].get("name")
        print("开始为 " + name + " 打卡...")
        # 随机UA
        with open(os.getcwd() + "/main/ua.txt", 'r', encoding='utf-8') as file:
            num = file.read().split("\n")
        UA = num[random.randint(0, len(num) - 1)]
        try:
            # 如果用户(users.json)填写含有schoolcode则设为对应学校
            # 否则设为滁州学院(外校同学设置为自己学校domain编码)
            # domain编码详见wiki或者course文件夹内的readme
            if "schoolcode" not in info[i]:
                info[i]['schoolcode'] = 'chzu'
            # 获取用户cookie
            cook = sign.login(info[i], UA)
            response = post.run(info[i]['schoolcode'], UA, cook)
        except Exception:
            print("---为 " + name + " 打卡失败\n")
            response = "打卡失败"
        # 为推送填写打卡信息
        text += "| {} | {} | \n".format(name, response)

print("打卡结束\n")

try:
    qq(
        time.strftime("%Y年%m月%d日") + "\n自动打卡任务已完成",
        text + "\n[点我查看运行状况](https://github.com/xsk666/autopost/actions)")
except requests.exceptions.ConnectionError:
    print("推送qq通知出错")
Пример #4
0
    if info[i].get("enable") == 'true':
        name = info[i].get("name")
        print("开始为 " + name + " 打卡...")
        # 随机UA
        with open(os.getcwd() + "/main/ua.txt", 'r', encoding='utf-8') as file:
            num = file.read().split("\n")
        UA = num[random.randint(0, len(num) - 1)]
        try:
            # 如果用户(users.json)填写含有schoolcode则设为对应学校
            # 否则设为滁州学院(外校同学设置为自己学校domain编码)
            # domain编码详见wiki或者course文件夹内的readme
            if "schoolcode" not in info[i]:
                info[i]['schoolcode'] = 'chzu'
            # 获取用户cookie
            cook = sign.login(info[i], UA)
            response = post.run(info[i], UA, cook)
        except Exception:
            print("---为 " + name + " 打卡失败\n")
            response = "打卡失败"
        # 为推送填写打卡信息
        text += "| {} | {} | \n".format(name, response)

print("打卡结束\n")

try:
    qq(
        time.strftime("%Y年%m月%d日") + "\n自动打卡任务已完成",
        text + "\n[点我查看运行状况](https://github.com/xsk666/autopost/actions)")
except requests.exceptions.ConnectionError:
    print("推送qq通知出错")
Пример #5
0
Файл: main.py Проект: nwf/dyna
def main():
    parser = argparse.ArgumentParser(description="The dyna interpreter!")

    parser.add_argument("--version", action="store_true", help="Print version information.")
    parser.add_argument("source", nargs="*", type=path, help="Path to Dyna source file.")
    parser.add_argument("-i", dest="interactive", action="store_true", help="Fire-up REPL after runing solver..")
    parser.add_argument("-o", "--output", dest="output", type=argparse.FileType("wb"), help="Write solution to file.")
    parser.add_argument("--post-process", nargs="*", help="run post-processor.")
    parser.add_argument("--load", nargs="*", help="run loaders.")
    parser.add_argument("--debug", action="store_true", help="Debug planner, normalizer and parser.")

    args = parser.parse_args()

    if args.version:
        try:
            print (dynahome / "dist/VERSION").text()  # XREF:VERSION
        except IOError:
            print "failed to obtain version info."
        exit(0)

    interp = Interpreter()

    crash_handler()

    if args.source:

        if len(args.source) > 1:
            # concatenate files
            with file(interp.compiler.tmp / "tmp.dyna", "wb") as g:
                for f in args.source:
                    if not f.exists():
                        print "File `%s` does not exist." % f
                        return
                    with file(f) as f:
                        g.write("\n")
                        g.write("%" * 80)
                        g.write("\n")
                        g.write("%% ")
                        g.write(f.name)
                        g.write("\n")
                        g.write(f.read())
            args.source = g.name
        else:
            [args.source] = args.source

        if not args.source.exists():
            print "File `%s` does not exist." % args.source
            return

        if args.debug:
            import debug

            debug.main(args.source, browser=True)
            exit(1)

        try:
            plan = interp.dynac(args.source)
        except DynaCompilerError as e:
            print e
            exit(1)

        interp.load_plan(plan)
        interp.run_agenda()

    if args.load:
        for cmd in args.load:
            load.run(interp, cmd)

    if args.post_process:
        for cmd in args.post_process:
            post.run(interp, cmd)

    if args.load or args.post_process or args.source:
        interp.dump_charts(args.output)  # should be a post-processor

    if args.interactive or not args.source:
        repl = REPL(interp)

        def repl_crash():
            # all files the interpreter generated
            with file(dotdynadir / "crash-repl.log", "wb") as f:
                for line in repl.lines:
                    print >> f, line

        crash_handler.hooks.append(repl_crash)

        repl.cmdloop()
Пример #6
0
def main():
    parser = argparse.ArgumentParser(description="The dyna interpreter!")

    parser.add_argument('--version',
                        action='store_true',
                        help='Print version information.')
    parser.add_argument('source',
                        nargs='*',
                        type=path,
                        help='Path to Dyna source file.')
    parser.add_argument('-i',
                        dest='interactive',
                        action='store_true',
                        help='Fire-up REPL after runing solver..')
    parser.add_argument('-o',
                        '--output',
                        dest='output',
                        type=argparse.FileType('wb'),
                        help='Write solution to file.')
    parser.add_argument('--post-process',
                        nargs='*',
                        help='run post-processor.')
    parser.add_argument('--load', nargs='*', help='run loaders.')
    parser.add_argument('--debug',
                        action='store_true',
                        help='Debug planner, normalizer and parser.')

    args = parser.parse_args()

    if args.version:
        try:
            print(dynahome / 'dist/VERSION').text()  # XREF:VERSION
        except IOError:
            print 'failed to obtain version info.'
        exit(0)

    interp = Interpreter()

    crash_handler()

    if args.source:

        if len(args.source) > 1:
            # concatenate files
            with file(interp.compiler.tmp / 'tmp.dyna', 'wb') as g:
                for f in args.source:
                    if not f.exists():
                        print 'File `%s` does not exist.' % f
                        return
                    with file(f) as f:
                        g.write('\n')
                        g.write('%' * 80)
                        g.write('\n')
                        g.write('%% ')
                        g.write(f.name)
                        g.write('\n')
                        g.write(f.read())
            args.source = g.name
        else:
            [args.source] = args.source

        if not args.source.exists():
            print 'File `%s` does not exist.' % args.source
            return

        if args.debug:
            import debug
            debug.main(args.source, browser=True)
            exit(1)

        try:
            plan = interp.dynac(args.source)
        except DynaCompilerError as e:
            print e
            exit(1)

        interp.load_plan(plan)
        interp.run_agenda()

    if args.load:
        for cmd in args.load:
            load.run(interp, cmd)

    if args.post_process:
        for cmd in args.post_process:
            post.run(interp, cmd)

    if args.load or args.post_process or args.source:
        interp.dump_charts(args.output)  # should be a post-processor

    if args.interactive or not args.source:
        repl = REPL(interp)

        def repl_crash():
            # all files the interpreter generated
            with file(dotdynadir / 'crash-repl.log', 'wb') as f:
                for line in repl.lines:
                    print >> f, line

        crash_handler.hooks.append(repl_crash)

        repl.cmdloop()