Beispiel #1
0
def regenerate_documentation(args, temp_dir, repositories):
    if args.badges_only is True or args.tags_only is True:
        return
    input(
        "About to regenerate documentation. Are you sure you want to continue? "
        + "(Press ENTER to continue)")
    update_doc_content_repository(repositories, temp_dir, args.token,
                                  args.no_push, args)
    write_msg('=> Preparing doc repo (too much dark magic in here urg)...')
    cleanup_doc_repo(temp_dir)
    write_msg('Done!')

    write_msg('=> Building docs...')
    for crate in args.crates:
        crate = crate['crate']
        if crate['crate'] == 'gtk-test':
            continue
        write_msg('-> Building docs for {}...'.format(crate['crate']))
        build_docs(crate['repository'], temp_dir, crate['path'],
                   crate.get('doc_name', crate['crate']))
    end_docs_build(temp_dir)
    write_msg('Done!')

    write_msg('=> Committing{} docs to the "{}" branch...'.format(
        " and pushing" if args.no_push is False else "",
        consts.CRATE_TMP_BRANCH))
    commit(consts.DOC_REPO, temp_dir, "Regen docs")
    if args.no_push is False:
        push(consts.DOC_REPO, temp_dir, consts.CRATE_TMP_BRANCH)
        create_pull_request(consts.DOC_REPO, consts.CRATE_TMP_BRANCH,
                            "gh-pages", args.token)
        write_msg("New pull request(s):\n\n{}\n".format(
            '\n'.join(PULL_REQUESTS)))
    write_msg('Done!')
Beispiel #2
0
def replay(trace, background=False, offset=0, delay=0, release_timeout=0.09):
    # args
    exe_local_path = 'mysendevent-arm64'
    exe_remote_path = '/data/local/tmp/mysendevent-arm64'
    trace_local_path = trace
    trace_remote_path = '/data/local/tmp/' + trace

    if option.event == "":
        touch_screen_event = find_touchscreen()
    else:
        touch_screen_event = option.event

    execute_command('adb shell ' + 'cd ' + '/data/local/tmp/')
    push(exe_local_path, exe_remote_path, force=True)
    push(trace_local_path, trace_remote_path, force=True)
    execute_command('adb shell ' + 'chmod +x ' +
                    exe_remote_path)  # 'Permission denied'
    if get_api_version() < 23:
        cmd_string = 'adb shell ' + exe_remote_path + ' -e ' + touch_screen_event + ' -t ' + trace_remote_path + \
           ' -o ' + str(offset) + ' -r ' + str(release_timeout) + ' -w '
    else:
        cmd_string = 'adb exec-out ' + exe_remote_path + ' -e ' + touch_screen_event + ' -t ' + trace_remote_path + \
           ' -o ' + str(offset) + ' -r ' + str(release_timeout) + ' -w '
    if option.huawei:
        cmd_string += ' -m huawei '
    if option.debug:
        cmd_string += ' -v '

    if background:
        execute_background(cmd_string, delay=delay, outfile=sys.stdout)
    else:
        execute_intercept(cmd_string, delay=delay, outfile=sys.stdout)
Beispiel #3
0
def update_crates_versions(args, temp_dir, repositories):
    write_msg('=> Updating [master] crates version...')
    for crate in args.crates:
        update_type = crate['up-type']
        crate = crate['crate']
        if args.specified_crate is not None and crate[
                'crate'] != args.specified_crate:
            continue
        if update_repo_version(crate["repository"], crate["crate"],
                               crate["path"], temp_dir, update_type,
                               args.badges_only or args.tags_only) is False:
            write_error('The update for the "{}" crate failed...'.format(
                crate["crate"]))
            return False
    write_msg('Done!')
    if args.badges_only is False and args.tags_only is False:
        write_msg('=> Committing{} to the "{}" branch...'.format(
            " and pushing" if args.no_push is False else "",
            consts.MASTER_TMP_BRANCH))
        for repo in repositories:
            commit(repo, temp_dir, "Update versions [ci skip]")
            if args.no_push is False:
                push(repo, temp_dir, consts.MASTER_TMP_BRANCH)
        write_msg('Done!')

        if args.no_push is False:
            write_msg('=> Creating PRs on master branch...')
            for repo in repositories:
                create_pull_request(repo, consts.MASTER_TMP_BRANCH, "master",
                                    args.token)
            write_msg('Done!')
    return True
Beispiel #4
0
def update_crate_repositories_branches(args, temp_dir, repositories):
    write_msg('=> Merging "master" branches into "crate" branches...')
    for repo in repositories:
        merging_branches(repo, temp_dir, "master")
    write_msg('Done!')

    write_msg('=> Updating [crate] crates version...')
    for crate in args.crates:
        crate = crate['crate']
        if args.specified_crate is not None and crate[
                'crate'] != args.specified_crate:
            continue
        if update_crate_version(crate["repository"], crate["crate"],
                                crate["path"], temp_dir,
                                args.specified_crate) is False:
            write_error('The update for the "{}" crate failed...'.format(
                crate["crate"]))
            return False
    write_msg('Done!')

    write_msg('=> Committing{} to the "{}" branch...'.format(
        " and pushing" if args.no_push is False else "",
        consts.CRATE_TMP_BRANCH))
    for repo in repositories:
        commit(repo, temp_dir, "Update versions [ci skip]")
        if args.no_push is False:
            push(repo, temp_dir, consts.CRATE_TMP_BRANCH)
    write_msg('Done!')
    if args.no_push is False:
        write_msg('=> Creating PRs on crate branch...')
        for repo in repositories:
            create_pull_request(repo, consts.CRATE_TMP_BRANCH, "crate",
                                args.token)
        write_msg('Done!')
    return True
Beispiel #5
0
def update_doc_content_repository(repositories, temp_dir, token, no_push,
                                  args):
    if clone_repo(consts.DOC_CONTENT_REPO, temp_dir) is False:
        input('Try to fix the problem then press ENTER to continue...')
    write_msg("Done!")
    repo_path = join(temp_dir, consts.DOC_CONTENT_REPO)
    write_msg("=> Generating documentation for crates...")
    for repo in repositories:
        current = None
        for crate in args.crates:
            crate = crate['crate']
            if crate['repository'] == repo:
                current = crate
                break
        if current is None:
            input(
                'No repository matches "{}", something is weird. (Press ENTER TO CONTINUE)'
            )
            continue
        if current.get("doc", True) is False:
            continue
        write_msg('==> Generating documentation for "{}"'.format(current))
        path = join(temp_dir, current['repository'])
        command = [
            'bash', '-c', 'cd {} && make doc && mv vendor.md {}'.format(
                path, join(repo_path, current['crate']))
        ]
        if not exec_command_and_print_error(command):
            input("Fix the error and then press ENTER")
    write_msg('Done!')
    write_msg('Committing "{}" changes...'.format(consts.DOC_CONTENT_REPO))
    commit(consts.DOC_CONTENT_REPO, temp_dir, "Update vendor files")
    if no_push is False:
        push(consts.DOC_CONTENT_REPO, temp_dir, consts.MASTER_TMP_BRANCH)

    # We always make minor releases in here, no need for a more important one considering we don't
    # change the API.
    if update_repo_version(consts.DOC_CONTENT_REPO, consts.DOC_CONTENT_REPO,
                           "", temp_dir, UpdateType.MINOR, False) is False:
        write_error('The update for the "{}" crate failed...'.format(
            consts.DOC_CONTENT_REPO))
        input('Fix the error and then press ENTER')
    commit(consts.DOC_CONTENT_REPO, temp_dir, "Update version")
    if no_push is False:
        push(consts.DOC_CONTENT_REPO, temp_dir, consts.MASTER_TMP_BRANCH)
        create_pull_request(consts.DOC_CONTENT_REPO, consts.MASTER_TMP_BRANCH,
                            "master", token, False)
        input((
            'All done with the "{}" update: please merge the PR then press ENTER so the '
            'publication can performed...').format(consts.DOC_CONTENT_REPO))
        publish_crate(consts.DOC_CONTENT_REPO,
                      "",
                      temp_dir,
                      consts.DOC_CONTENT_REPO,
                      checkout_branch='master')
        write_msg('Ok all done! We can move forward now!')
    else:
        write_msg((
            'All with "{}", you still need to publish a new version if you want the changes '
            'to be taken into account').format(consts.DOC_CONTENT_REPO))
Beispiel #6
0
def build_translation(apps, _pull=False):
    """ build frappe app's translation """
    from utils import config

    config_apps = config.get("apps")
    update_bench = config.get("update_bench")
    release_bench = config.get("release_bench")
    release_bench_site = config.get("release_bench_site")
    update_bench_site = config.get("update_bench_site")
    commit_msg = config.get(
        "translation_commit_msg") or "[docs] Updated translation"
    base_branches = config.get("base_branch_mapper") or {}

    # import source messages
    exec_cmd(
        update_bench,
        ['bench --site {0} import-source-messages'.format(update_bench_site)])

    # translate unstranslated messages
    exec_cmd(update_bench, [
        'bench --site {0} translate-untranslated-all'.format(update_bench_site)
    ])

    # write csv
    exec_cmd(update_bench, [
        'bench --site {0} execute "translator.data.write_csv_for_all_languages"'
        .format(update_bench_site)
    ])

    # download the translation csv to frappe/erpnext app
    exec_cmd(release_bench, ['bench download-translations'])
    branch = "translations-{0}".format(now_date(format='%Y.%m.%d'))
    try:
        for app in config_apps:
            path = os.path.join(release_bench, 'apps', app)
            if app not in apps:
                exec_cmd(path, ['git stash'])

            if not path:
                print "app is not installed"
                continue

            base_branch = base_branches.get(app, "develop")
            if _pull:
                pull(path, "upstream", base_branch)
            checkout(path, branch, create_new=True)

            args = [
                '{branch}:{branch}'.format(branch=branch),
            ]
            push(app, path, branch, commit_msg)
            pull_request(app, commit_msg, branch, base=base_branch)
            checkout(path,
                     base_branch,
                     delete_branch_after_checkout=True,
                     delete_branch=branch)
    except Exception as e:
        print e
Beispiel #7
0
 def __init__(self,
              message_type,
              user,
              launch,
              post_comment=None,
              is_read=False):
     self.message_type_id = message_type.id
     self.user_id = user.id
     self.launch_id = launch.id if launch else 0
     self.post_comment_id = post_comment.id if post_comment else 0
     self.is_read = is_read
     comment = post_comment.content if post_comment else None
     push(message_type.type, user, launch, comment)
Beispiel #8
0
def notify():
    reader = codecs.getreader("utf-8")
    data = json.load(reader(request.body))
    userID=data['userID']    
    token=data['token']
    sql="select * from Token where userID ='%s' and generatedToken='%s'" % (userID, token)
    result=mysql.query(sql,1)
    if not result:
        return json.dumps({"status":"wrong"})
    toUserID=data['toUserID']
    message=data['message']
    sql="select regID from androidRegID where userID ='%s' " %(toUserID);
    regID=mysql.query(sql,1)
    utils.push(regID, message)
Beispiel #9
0
def build_docs(apps, _pull=False):
    """ build frappe app's documentation """
    from utils import config

    release_bench = config.get("release_bench")
    release_bench_site = config.get("release_bench_site")
    commit_msg = config.get("docs_commit_msg")
    target_app_mapper = config.get("docs_target_apps")
    base_branches = config.get("base_branch_mapper") or {}

    branch = "docs-{0}".format(now_date(format='%Y.%m.%d'))
    for app in apps:
        try:
            apps_path = os.path.join(release_bench, 'apps', app)
            if not apps_path:
                print "app is not installed"

            target = target_app_mapper.get(app, {})
            target_app = target.get("app", None)
            owner = target.get("owner", None)
            if not target_app or not owner:
                print "target app mapping not available"

            target_app_path = os.path.join(release_bench, 'apps', target_app)
            if not target_app_path:
                print "app is not installed"

            if _pull:
                pull(apps_path, "upstream", base_branches.get(app, "develop"))
                pull(target_app_path, "upstream",
                     base_branches.get(target_app, "master"))

            checkout(target_app_path, branch, create_new=True)

            # build docs
            exec_cmd(release_bench, \
             ['bench --site {0} build-docs --target {1} {2}'.format(release_bench_site, target_app, app)])

            push(app, target_app_path, branch, commit_msg, commit=True)
            pull_request(target_app,
                         commit_msg,
                         branch,
                         base=base_branches.get(target_app, "master"),
                         owner=owner)
            checkout(target_app_path,
                     base_branches.get(target_app, "master"),
                     delete_branch_after_checkout=False,
                     delete_branch=branch)
        except Exception as e:
            print e
Beispiel #10
0
def generate_new_branches(repository, temp_dir, specified_crate, args):
    # We make a new branch for every crate based on the current "crate" branch:
    #
    # * If it is a "sys" crate, then we ignore it.
    # * If not, then we create a new branch
    for crate in args.crates:
        crate = crate['crate']
        if crate['repository'] == repository:
            if specified_crate is not None and crate[
                    'crate'] != specified_crate:
                continue
            if crate['crate'].endswith('-sys') or crate['crate'].endswith(
                    '-sys-rs'):
                continue
            branch_name = CRATES_VERSION[crate['crate']]
            write_msg(
                '==> Creating new branch "{}" for repository "{}"...'.format(
                    branch_name, repository))
            push(repository, temp_dir, branch_name)
Beispiel #11
0
    def save_order(self, order, ad, adid, user, points,
                   price, time, device, sign, trade_type):
        """保存订单"""
        user_info = users.get_info_byphone(user)
        if not user_info:
            user_info = users.get_info(user)
            if not user_info:
                return self.write('not user')
        # 小助手不加积分
        if int(adid) == 7658:
            return self.write('qiankaxiaozhushou')
        rate = options.get('rate')
        # 用户被邀请
        if user_info['parent']:
            parent = users.get_info(int(user_info['parent']))
            if parent['platform'] == user_info['platform'] and user_info['platform'] != 0:
                reward.task_prorate(user_info, int(points))
                # 师傅收益缓存今日赚取
                if parent['vip'] == 1:
                    iv_prorate = options.get('vip')
                else:
                    iv_prorate = options.get('iv_parent')
                self._today_earn(user_info['parent'],"%.2f" %(int(points) * int(iv_prorate)/100))
        if user_info['grandfather']:
            grandfather = users.get_info(int(user_info['grandfather']))
            if grandfather['platform'] == user_info['platform'] and user_info['platform'] != 0:
                iv_gprorate = options.get('iv_grandfather')
                self._today_earn(user_info['grandfather'], "%.2f" %(int(points) * int(iv_gprorate)/100))
        if user_info['parent'] or user_info['grandfather']:
            count_otype = int(orders.count_callback_orders(user_info['uid'])['dcount'])
            if count_otype == 0:
                parent = users.get_info(user_info['parent'])
                if parent['platform'] == user_info['platform'] and user_info['platform'] != 0:
                    self._today_earn(user_info['parent'], 2*int(rate))
                    note = u'您的徒弟完成任务,奖励师傅2元'
                    oid = orders.new_global_order(user_info['parent'], parent['points'], 2*int(rate), orders.OTYPE_INVITE, note)
                    users.add_iv_points(parent['uid'], 2*int(rate))
        order_info = orders.get_callback_order(order)
        if not order_info:
            if int(trade_type) == 1 or trade_type == '':
                note = u"恭喜您成功下载安装 %s ,获得奖励" % ad
                # 试玩奖励
                task = tasks.get_task_info(user_info['uid'], 1)
                if not task:
                    earn = tasks.get_task_byid(1)
                    orders.new_global_order(user_info['uid'], user_info['points'], earn,
                    1, '恭喜您完成新手任务-首次试玩 ,获得奖励')
                    tasks.new_task(user_info['uid'], 1)
                    users.add_tt_points(user_info['uid'], earn)
                    self._today_earn(user_info['uid'], earn)
            elif int(trade_type) == 2:
                note = u"恭喜您完成追加任务 %s ,获得奖励" % ad
                task = tasks.get_task_info(user_info['uid'], 4)
                if not task:
                    earn = tasks.get_task_byid(4)
                    orders.new_global_order(user_info['uid'], user_info['points'], earn,
                    1, '恭喜您完成新手任务-首次深度任务 ,获得奖励')
                    tasks.new_task(user_info['uid'], 4)
                    users.add_tt_points(user_info['uid'], earn)
                    self._today_earn(user_info['uid'], earn)

            oid = orders.new_global_order(
                user_info['uid'], user_info['points'], points,
                orders.OTYPE_TASK, note)
            users.add_tt_points(user_info['uid'], points)
            price = "%.2f" % (float(points)/int(rate))
            msg = note +  str(price) +u'元'
            params = {
                "order": order,
                "oid": oid,
                "ad": ad,
                "adid": adid,
                "uid": user_info['uid'],
                "points": points,
                "price": price,
                "device": device,
                "sig": sign,
                "platform": self._platform,
                "trade_type": trade_type,
                "pkg" : user_info['pkg']
            }
            orders.new_callback_order(**params)
            self._today_earn(user_info['uid'], points)
            self._callback_record(user_info['uid'], ad, adid, points)
            utils.push(user_info['phone'],msg.encode('utf-8'))
Beispiel #12
0
def push_msg(phone, msg):
    try:
        utils.push(phone, msg)
    except:
        pass
Beispiel #13
0
def test_message():
    from utils import push
    push('comment', User.query.get(4), User.query.get(1), u'富贵全靠大左')