本文整理汇总了Python中utils.td_helper.send_td_event函数的典型用法代码示例。如果您正苦于以下问题:Python send_td_event函数的具体用法?Python send_td_event怎么用?Python send_td_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send_td_event函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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())})
示例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
})
示例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
})
示例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)
})
示例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
}
}
示例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
示例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()]
}})
示例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
})
示例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)
示例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")
示例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({})
示例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)
示例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)
示例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)
)
示例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