push2clip.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:push2clip 作者: kf5grd 项目源码 文件源码
def cli(ctx, message, key, config, verbose):
    """Use simplepush and tasker to push text to remote phone's clipboard."""

    if ctx.invoked_subcommand is None:
        if not os.path.exists(config):
            click.echo("Config file: {}".format(config))
            click.echo("Config file does not exist. Please choose a different file, or initialize with push2clip init <key>")
            quit()

        with open(config, 'r') as f:
            conf = json.load(f)
            f.close()

        if not key:
            if not conf['key']:
                print("Error: Simplepush key is missing. Unable to send push.")
                quit()
            key = conf['key']

        if not message:
            message = click.get_text_stream('stdin').read()

        event = conf.get("event", '')
        title = conf.get("title", '')

        sp = simplepush(key, event=event, title=title, message=message) 
        if not sp:
            click.echo("An error was encountered while pushing message.")
        else:
            if verbose:
                click.echo("Push sent successfully.")
                click.echo("Key: {}".format(key))
                click.echo("Event: {}".format(event))
                click.echo("Title: {}".format(title))
                click.echo("Message: {}".format(message))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号