• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python td_helper.send_td_event函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utils.td_helper.send_td_event函数的典型用法代码示例。如果您正苦于以下问题:Python send_td_event函数的具体用法?Python send_td_event怎么用?Python send_td_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了send_td_event函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: save_source_file

def save_source_file(request, project_id, file_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    source_file = get_object_or_404(SourceFile, pk=file_id, project=project)
    try:
        if source_file.was_modified_since(int(request.POST['modified'])):
            send_td_event('cloudpebble_save_abort_unsafe', data={
                'data': {
                    'filename': source_file.file_name,
                    'kind': 'source'
                }
            }, request=request, project=project)
            raise Exception(_("Could not save: file has been modified since last save."))
        source_file.save_file(request.POST['content'], folded_lines=request.POST['folded_lines'])

    except Exception as e:
        return json_failure(str(e))
    else:
        send_td_event('cloudpebble_save_file', data={
            'data': {
                'filename': source_file.file_name,
                'kind': 'source'
            }
        }, request=request, project=project)

        return json_response({"modified": time.mktime(source_file.last_modified.utctimetuple())})
开发者ID:lochotzke,项目名称:cloudpebble,代码行数:25,代码来源:source.py


示例2: view_project

def view_project(request, project_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    if project.app_uuid is None:
        project.app_uuid = generate_half_uuid()
    if project.app_company_name is None:
        project.app_company_name = request.user.username
    if project.app_short_name is None:
        project.app_short_name = project.name
    if project.app_long_name is None:
        project.app_long_name = project.app_short_name
    if project.app_version_label is None:
        project.app_version_label = '1.0'
    app_keys = project.get_parsed_appkeys()
    supported_platforms = ["aplite", "basalt"]
    if project.project_type != 'pebblejs' and project.sdk_version != '2':
        supported_platforms.append("chalk")

    send_td_event('cloudpebble_open_project', request=request, project=project)
    try:
        token = request.user.social_auth.get(provider='pebble').extra_data['access_token']
    except:
        token = ''
    return render(request, 'ide/project.html', {
        'project': project,
        'app_keys': app_keys,
        'font_css': settings.TYPOGRAPHY_CSS,
        'libpebble_proxy': json.dumps(settings.LIBPEBBLE_PROXY),
        'token': token,
        'phone_shorturl': settings.PHONE_SHORTURL,
        'supported_platforms': supported_platforms,
        'version_regex': SDK_VERSION_REGEX,
        'npm_manifest_support_enabled': settings.NPM_MANIFEST_SUPPORT
    })
开发者ID:amuelli,项目名称:cloudpebble,代码行数:33,代码来源:project.py


示例3: load_source_file

def load_source_file(request, project_id, file_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    source_file = get_object_or_404(SourceFile, pk=file_id, project=project)
    try:
        content = source_file.get_contents()

        try:
            folded_lines = json.loads(source_file.folded_lines)
        except ValueError:
            folded_lines = []

        send_td_event('cloudpebble_open_file', data={
            'data': {
                'filename': source_file.file_name,
                'kind': 'source'
            }
        }, request=request, project=project)

    except Exception as e:
        return json_failure(str(e))
    else:
        return json_response({
            "success": True,
            "source": content,
            "modified": time.mktime(source_file.last_modified.utctimetuple()),
            "folded_lines": folded_lines
        })
开发者ID:lochotzke,项目名称:cloudpebble,代码行数:27,代码来源:source.py


示例4: view_project

def view_project(request, project_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    if project.app_uuid is None:
        project.app_uuid = generate_half_uuid()
    if project.app_company_name is None:
        project.app_company_name = request.user.username
    if project.app_short_name is None:
        project.app_short_name = project.name
    if project.app_long_name is None:
        project.app_long_name = project.app_short_name
    if project.app_version_label is None:
        project.app_version_label = '1.0'
    app_keys = project.get_parsed_appkeys()

    send_td_event('cloudpebble_open_project', request=request, project=project)
    try:
        token = request.user.social_auth.get(provider='pebble').extra_data['access_token']
    except:
        token = ''
    return render(request, 'ide/project.html', {
        'project': project,
        'app_keys': app_keys,
        'font_css': settings.TYPOGRAPHY_CSS,
        'libpebble_proxy': json.dumps(settings.LIBPEBBLE_PROXY),
        'token': token,
        'phone_shorturl': settings.PHONE_SHORTURL,
        'supported_platforms': project.supported_platforms,
        'regexes': regexes,
        'regexes_json': json.dumps(regexes.regex_dictionary)
    })
开发者ID:boredwookie,项目名称:cloudpebble,代码行数:30,代码来源:project.py


示例5: create_source_file

def create_source_file(request, project_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    try:
        f = SourceFile.objects.create(project=project,
                                      file_name=request.POST['name'],
                                      target=request.POST.get('target', 'app'))
        f.save_text(request.POST.get('content', ''))

    except IntegrityError as e:
        raise BadRequest(str(e))

    send_td_event('cloudpebble_create_file', data={
        'data': {
            'filename': request.POST['name'],
            'kind': 'source',
            'target': f.target
        }
    }, request=request, project=project)

    return {
        'file': {
            'id': f.id,
            'name': f.file_name,
            'target': f.target,
            'file_path': f.project_path
        }
    }
开发者ID:boredwookie,项目名称:cloudpebble,代码行数:27,代码来源:source.py


示例6: do_import_github

def do_import_github(project_id, github_user, github_project, github_branch, delete_project=False):
    try:
        url = "https://github.com/%s/%s/archive/%s.zip" % (github_user, github_project, github_branch)
        if file_exists(url):
            u = urllib2.urlopen(url)
            return do_import_archive(project_id, u.read())
        else:
            raise Exception("The branch '%s' does not exist." % github_branch)
    except Exception as e:
        try:
            project = Project.objects.get(pk=project_id)
            user = project.owner
        except:
            project = None
            user = None
        if delete_project and project is not None:
            try:
                project.delete()
            except:
                pass
        send_td_event('cloudpebble_github_import_failed', data={
            'data': {
                'reason': e.message,
                'github_user': github_user,
                'github_project': github_project,
                'github_branch': github_branch
            }
        }, user=user)
        raise
开发者ID:amuelli,项目名称:cloudpebble,代码行数:29,代码来源:git.py


示例7: delete_variant

def delete_variant(request, project_id, resource_id, variant):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    resource = get_object_or_404(ResourceFile, pk=resource_id, project=project)
    if variant == '0':
        variant = ''
    variant_to_delete = resource.variants.get(tags=variant)

    if resource.variants.count() == 1:
        return json_failure("You cannot delete the last remaining variant of a resource.")
    try:
        variant_to_delete.delete()
    except Exception as e:
        return json_failure(str(e))
    else:
        send_td_event('cloudpebble_delete_variant', data={
            'data': {
                'filename': resource.file_name,
                'kind': 'resource',
                'resource-kind': resource.kind,
                'variant': variant
            }
        }, request=request, project=project)

        return json_response({'resource': {
            'variants': [x.get_tags() for x in resource.variants.all()]
        }})
开发者ID:lochotzke,项目名称:cloudpebble,代码行数:26,代码来源:resource.py


示例8: view_project

def view_project(request, project_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    if project.app_uuid is None:
        project.app_uuid = generate_half_uuid()
    if project.app_company_name is None:
        project.app_company_name = request.user.username
    if project.app_short_name is None:
        project.app_short_name = project.name
    if project.app_long_name is None:
        project.app_long_name = project.app_short_name
    if project.app_version_label is None:
        project.app_version_label = '1.0'
    send_td_event('cloudpebble_open_project', request=request, project=project)
    app_keys = sorted(json.loads(project.app_keys).iteritems(), key=lambda x: x[1])
    supported_platforms = ["aplite", "basalt"]
    if project.project_type != 'pebblejs' and project.sdk_version != '2':
        supported_platforms.append("chalk")

    try:
        token = request.user.social_auth.get(provider='pebble').extra_data['access_token']
    except:
        token = ''
    return render(request, 'ide/project.html', {
        'project': project,
        'app_keys': app_keys,
        'font_css': settings.TYPOGRAPHY_CSS,
        'libpebble_proxy': json.dumps(settings.LIBPEBBLE_PROXY),
        'token': token,
        'phone_shorturl': settings.PHONE_SHORTURL,
        'supported_platforms': supported_platforms
    })
开发者ID:lochotzke,项目名称:cloudpebble,代码行数:31,代码来源:project.py


示例9: save_project_dependencies

def save_project_dependencies(request, project_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    try:
        project.set_dependencies(json.loads(request.POST['dependencies']))
    except (IntegrityError, ValueError) as e:
        raise BadRequest(str(e))
    else:
        send_td_event('cloudpebble_save_project_settings', request=request, project=project)
开发者ID:amuelli,项目名称:cloudpebble,代码行数:8,代码来源:project.py


示例10: remove_github_auth

def remove_github_auth(request):
    try:
        user_github = request.user.github
        user_github.delete()
    except UserGithub.DoesNotExist:
        pass
    send_td_event("cloudpebble_github_revoked", request=request)
    return HttpResponseRedirect("/ide/settings")
开发者ID:pebble,项目名称:cloudpebble,代码行数:8,代码来源:settings.py


示例11: delete_project

def delete_project(request, project_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    if not bool(request.POST.get('confirm', False)):
        return json_failure("Not confirmed")
    try:
        project.delete()
    except Exception as e:
        return json_failure(str(e))
    else:
        send_td_event('cloudpebble_delete_project', request=request, project=project)
        return json_response({})
开发者ID:lochotzke,项目名称:cloudpebble,代码行数:11,代码来源:project.py


示例12: delete_resource

def delete_resource(request, project_id, resource_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    resource = get_object_or_404(ResourceFile, pk=resource_id, project=project)

    resource.delete()
    send_td_event('cloudpebble_delete_file', data={
        'data': {
            'filename': resource.file_name,
            'kind': 'resource',
            'resource-kind': resource.kind
        }
    }, request=request, project=project)
开发者ID:boredwookie,项目名称:cloudpebble,代码行数:12,代码来源:resource.py


示例13: delete_source_file

def delete_source_file(request, project_id, file_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    source_file = get_object_or_404(SourceFile, pk=file_id, project=project)

    source_file.delete()

    send_td_event('cloudpebble_delete_file', data={
        'data': {
            'filename': source_file.file_name,
            'kind': 'source'
        }
    }, request=request, project=project)
开发者ID:amuelli,项目名称:cloudpebble,代码行数:12,代码来源:source.py


示例14: start_github_auth

def start_github_auth(request):
    nonce = uuid.uuid4().hex
    try:
        user_github = request.user.github
    except UserGithub.DoesNotExist:
        user_github = UserGithub.objects.create(user=request.user)
    user_github.nonce = nonce
    user_github.save()
    send_td_event("cloudpebble_github_started", request=request)
    return HttpResponseRedirect(
        "https://github.com/login/oauth/authorize?client_id=%s&scope=repo&state=%s" % (settings.GITHUB_CLIENT_ID, nonce)
    )
开发者ID:pebble,项目名称:cloudpebble,代码行数:12,代码来源:settings.py


示例15: npm_search

def npm_search(request):
    try:
        query = request.GET['q']
    except KeyError:
        return {'packages': []}
    search = requests.get('http://node-modules.com/search.json', {'q': query}).json()
    data = {'packages': [filter_dict(package, PACKAGE_SPEC) for package in search]}
    send_td_event('cloudpebble_package_search', data={
        'data': {
            'query': query
        }
    }, request=request)
    return data
开发者ID:amuelli,项目名称:cloudpebble,代码行数:13,代码来源:npm.py


示例16: build_log

def build_log(request, project_id, build_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    build = get_object_or_404(BuildResult, project=project, pk=build_id)

    log = build.read_build_log()

    send_td_event('cloudpebble_view_build_log', data={
        'data': {
            'build_state': build.state
        }
    }, request=request, project=project)

    return {"log": log}
开发者ID:boredwookie,项目名称:cloudpebble,代码行数:13,代码来源:project.py


示例17: get_shortlink

def get_shortlink(request):
    from utils.td_helper import send_td_event
    url = request.POST['url']
    try:
        r = urllib2.Request('http://api.small.cat/entries', json.dumps({'value': url, 'duration': 60}), headers={'Content-Type': 'application/json'})
        response = json.loads(urllib2.urlopen(r).read())
    except urllib2.URLError as e:
        return json_failure(str(e))
    else:
        send_td_event('cloudpebble_generate_shortlink', data={
            'data': {'short_url': response['url']}
        }, request=request)
        return json_response({'url': response['url']})
开发者ID:amuelli,项目名称:cloudpebble,代码行数:13,代码来源:__init__.py


示例18: build_log

def build_log(request, project_id, build_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    build = get_object_or_404(BuildResult, project=project, pk=build_id)
    try:
        log = build.read_build_log()
    except Exception as e:
        return json_failure(str(e))

    send_td_event('cloudpebble_view_build_log', data={
        'data': {
            'build_state': build.state
        }
    }, request=request, project=project)

    return json_response({"log": log})
开发者ID:lochotzke,项目名称:cloudpebble,代码行数:15,代码来源:project.py


示例19: delete_source_file

def delete_source_file(request, project_id, file_id):
    project = get_object_or_404(Project, pk=project_id, owner=request.user)
    source_file = get_object_or_404(SourceFile, pk=file_id, project=project)
    try:
        source_file.delete()
    except Exception as e:
        return json_failure(str(e))
    else:
        send_td_event('cloudpebble_delete_file', data={
            'data': {
                'filename': source_file.file_name,
                'kind': 'source'
            }
        }, request=request, project=project)
        return json_response({})
开发者ID:lochotzke,项目名称:cloudpebble,代码行数:15,代码来源:source.py


示例20: proxy_keen

def proxy_keen(request, project_id):
    from utils.td_helper import send_td_event
    project = get_object_or_404(Project, pk=project_id)

    acceptable_events = {
        'app_install_succeeded',
        'websocket_connection_failed',
        'app_install_failed',
        'app_log_view',
        'app_log_clear',
        'app_log_download',
        'app_logged_crash',
        'sdk_screenshot_success',
        'sdk_screenshot_failed',
        'cloudpebble_created_ui_layout',
        'cloudpebble_ib_displayed',
        'cloudpebble_ib_created_layer',
        'cloudpebble_android_beta_modal',
        'cloudpebble_android_beta_download',
        'qemu_launched',
        'cloudpebble_timeline_displayed',
        'sdk_pin_inserted',
        'sdk_pin_deleted',
        'cloudpebble_fuzzyprompt_action'
    }

    event = request.POST['event']
    if event not in acceptable_events:
        return json_failure("nope.")

    data = {}
    if 'data' in request.POST:
        data['data'] = json.loads(request.POST['data'])

    if 'device' in request.POST:
        data['device'] = json.loads(request.POST['device'])

    collections = ['cloudpebble', 'sdk']
    if 'collections' in request.POST:
        collections = list(set(collections) & set(json.loads(request.POST['collections'])))

    if len(data.items()) == 0:
        data = None

    send_td_event(event, data=data, request=request, project=project)
    return json_response({})
开发者ID:amuelli,项目名称:cloudpebble,代码行数:46,代码来源:__init__.py



注:本文中的utils.td_helper.send_td_event函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap