How to use isprivate method in Contexts

Best Python code snippet using Contexts

Run Contexts automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

file.py

Source: file.py Github

copy
1#!/usr/bin/env python2
2# coding=utf8
3
4from __future__ import absolute_import, division, print_function
5
6from flask import request, redirect
7from webargs import Arg
8
9from walis.service import (
10    get_file_url,
11    upload_file,
12    delete_file,
13)
14from walis.utils.http import args_parser, jsonpickle_dumps
15
16
17def get(file_hash):
18    args = args_parser.parse_all()
19    isprivate=args.get('isprivate',False)
20    file_url = get_file_url(file_hash,isprivate=isprivate)
21    return {'file_url': file_url}
22
23
24def upload():
25    # TODO try to parse file in webargs **********
26    image_file = request.files['file']
27    args = args_parser.parse_all()
28    isprivate=args.get('isprivate',False)
29    file_hash = upload_file(image_file,isprivate=isprivate)
30    return {'file_hash': file_hash}
31
32
33def delete():
34    args = args_parser.parse_all()
35    isprivate=args.get('isprivate',False)
36    file_hash = args_parser.parse(
37        {'file_hash': Arg(str), }).get('file_hash')
38
39    delete_file(file_hash,isprivate=isprivate)
40    return ''
41
42def hash2url(hash):
43    '''
44    :return: redirect to real image url via hash
45    '''
46    args = args_parser.parse_all()
47    isprivate=args.get('isprivate',False)
48    return redirect(get_file_url(hash,isprivate=isprivate))
49
Full Screen

aimingProcs.py

Source: aimingProcs.py Github

copy
1#Embedded file name: c:/depot/games/branches/release/EVE-TRANQUILITY/carbon/common/script/entities/AI/aimingProcs.py
2import zaction
3import perception
4import batma
5
6def GetAITargetList(propRow):
7    retList = []
8    for target in const.aiming.AIMING_VALID_TARGETS.values():
9        name = target[const.aiming.AIMING_VALID_TARGETS_FIELD_NAME]
10        clientServerFlag = target[const.aiming.AIMING_VALID_TARGETS_FIELD_CLIENTSERVER_FLAG]
11        if clientServerFlag != const.aiming.AIMING_CLIENTSERVER_FLAG_BOTH:
12            name = name + const.aiming.AIMING_CLIENTSERVER_FLAGS[clientServerFlag]
13        retList.append((name, target[const.aiming.AIMING_VALID_TARGETS_FIELD_ID], ''))
14
15    return retList
16
17
18exports = {'actionProperties.AITarget': ('listMethod', GetAITargetList),
19 'actionProcTypes.TargetSelect': zaction.ProcTypeDef(isMaster=False, procCategory='AI', properties=[zaction.ProcPropertyTypeDef('Target', 'I', userDataType='AITarget', isPrivate=True, displayName='Set Target'),
20                                  zaction.ProcPropertyTypeDef('Candidate', 'I', userDataType='AICandidate', isPrivate=True, displayName='From Candidate List'),
21                                  zaction.ProcPropertyTypeDef('Subject', 'I', userDataType='AISubject', isPrivate=True, displayName='Where Subject is'),
22                                  zaction.ProcPropertyTypeDef('Confidence', 'I', userDataType='AIConfidence', isPrivate=True, displayName='If Confidence >='),
23                                  zaction.ProcPropertyTypeDef('ConfidenceWeight', 'B', userDataType=None, isPrivate=True, displayName='Confidence weighting'),
24                                  zaction.ProcPropertyTypeDef('DistanceNearest', 'B', userDataType=None, isPrivate=True, displayName='Pick Nearest'),
25                                  zaction.ProcPropertyTypeDef('DistanceMin', 'F', userDataType=None, isPrivate=True, displayName='Minimum distance'),
26                                  zaction.ProcPropertyTypeDef('DistanceOptimal', 'F', userDataType=None, isPrivate=True, displayName='Optimal distance'),
27                                  zaction.ProcPropertyTypeDef('Tags', 'S', userDataType=None, isPrivate=True, displayName='Tags')], description='Select a target if possible.'),
28 'actionProcTypes.TargetSelectable': zaction.ProcTypeDef(isMaster=False, isConditional=True, procCategory='AI', properties=[zaction.ProcPropertyTypeDef('Target', 'I', userDataType='AITarget', isPrivate=True, displayName='Set Target'),
29                                      zaction.ProcPropertyTypeDef('Candidate', 'I', userDataType='AICandidate', isPrivate=True, displayName='From Candidate List'),
30                                      zaction.ProcPropertyTypeDef('Subject', 'I', userDataType='AISubject', isPrivate=True, displayName='Where Subject is'),
31                                      zaction.ProcPropertyTypeDef('Confidence', 'I', userDataType='AIConfidence', isPrivate=True, displayName='If Confidence >='),
32                                      zaction.ProcPropertyTypeDef('ConfidenceWeight', 'B', userDataType=None, isPrivate=True, displayName='Confidence weighting'),
33                                      zaction.ProcPropertyTypeDef('DistanceNearest', 'B', userDataType=None, isPrivate=True, displayName='Pick Nearest'),
34                                      zaction.ProcPropertyTypeDef('DistanceMin', 'F', userDataType=None, isPrivate=True, displayName='Minimum distance'),
35                                      zaction.ProcPropertyTypeDef('DistanceOptimal', 'F', userDataType=None, isPrivate=True, displayName='Optimal distance'),
36                                      zaction.ProcPropertyTypeDef('Tags', 'S', userDataType=None, isPrivate=True, displayName='Tags')], description='Test if a target would be selected. No target is selected'),
37 'actionProcTypes.TargetClear': zaction.ProcTypeDef(isMaster=False, procCategory='AI', properties=[zaction.ProcPropertyTypeDef('Target', 'I', userDataType='AITarget', isPrivate=True)], description='Clears the target'),
38 'actionProcTypes.TargetPreventSelect': zaction.ProcTypeDef(isMaster=False, procCategory='AI', properties=[zaction.ProcPropertyTypeDef('Target', 'I', userDataType='AITarget', isPrivate=True), zaction.ProcPropertyTypeDef('Time', 'F', userDataType=None, isPrivate=True, displayName='Time in secs')], description='Prevents re-selection of the current target for a period of time'),
39 'actionProcTypes.TargetIsSelected': zaction.ProcTypeDef(isMaster=False, isConditional=True, procCategory='AI', properties=[zaction.ProcPropertyTypeDef('Target', 'I', userDataType='AITarget', isPrivate=True)], description='Do we have a target'),
40 'actionProcTypes.TargetPreventListClearAll': zaction.ProcTypeDef(isMaster=False, procCategory='AI', properties=[zaction.ProcPropertyTypeDef('Target', 'I', userDataType='AITarget', isPrivate=True)], description='Clear the prevent selection list'),
41 'actionProcTypes.TargetSelectedEntity': zaction.ProcTypeDef(isMaster=False, procCategory='AI', properties=[zaction.ProcPropertyTypeDef('Target', 'I', userDataType='AITarget', isPrivate=True)], description="Target the player's selected entity. Used by head tracking"),
42 'actionProcTypes.TargetSelectFromHate': zaction.ProcTypeDef(isMaster=False, procCategory='AI', properties=[zaction.ProcPropertyTypeDef('Target', 'I', userDataType='AITarget', isPrivate=True, displayName='Set Target')], description='Select a target from the hate list.')}
Full Screen

views.py

Source: views.py Github

copy
1#Create your views here.
2from django.core.cache import cache
3from django.conf import settings
4from django.views.generic.simple import direct_to_template
5from blog.models import Blog, Status
6from auth.models import User
7from lib import dateutil
8
9def index(request):
10  blogs = Blog.objects.all().order_by('-date')
11  result = User.objects.all().filter(username = 'paullzn')
12  if len(result) > 0:
13    paullzn = result[0]
14  else:
15    paullzn = "paullzn"
16  result = User.objects.all().filter(username = 'lisa')
17  if len(result) > 0:
18    lisa = result[0]
19  else:
20    lisa = "lisa"
21
22  try:
23    p_status = Status.objects.all().filter(author = paullzn ).order_by('-created_at')[0].content
24  except IndexError:
25    p_status = "nothing.."
26  try:
27    l_status = Status.objects.all().filter(author = lisa ).order_by('-created_at')[0].content
28  except IndexError:
29    l_status = "nothing.."
30
31  try:
32    username = request.session['user']
33  except KeyError:
34    username = 'anonymous'
35
36  displays = []
37
38  for blog in blogs:
39    d = dateutil.date_to_local(blog.date)
40    if username != 'anonymous' or blog.isprivate == 0:
41      displays.append({'author': blog.author.username, \
42          'content': blog.content, \
43          'date': d, \
44          'isprivate': blog.isprivate, \
45          'title': blog.title})
46
47  return direct_to_template(request, 'blog/index.html',
48      {'username': username,
49      'p_status': p_status,
50      'l_status': l_status,
51      'blogs': displays,
52      'page': 'blog'})
53
54from django.http import HttpResponseRedirect
55from auth.models import User
56
57def status_up(request):
58  if request.method == 'POST':
59    try:
60      user_id = request.session['user_id']
61    except KeyError:
62      return HttpResponseRedirect('/blog/')
63    
64    status = Status()
65    status.author = User.objects.get( id = user_id)
66    status.content = request.POST.get('status')
67    status.save()
68    
69  return HttpResponseRedirect('/blog/')
70
71def create(request):
72  if request.method == 'POST':
73    blog = Blog()
74    blog.title = request.POST.get('title')
75    blog.content = request.POST.get('content')
76    greeting.isprivate = request.POST.get('isprivate')
77    if greeting.isprivate == None:
78      greeting.isprivate = 0
79    greeting.isprivate = request.POST.get('isprivate')
80    if greeting.isprivate == None:
81      greeting.isprivate = 0
82  
83  try:
84    user_id = request.session['user_id']
85    greeting.save()
86  except KeyError:
87    greeting.author = 'anonymous'
88  
89  greeting.save()
90  
91  return HttpResponseRedirect('/greeting/')
92  
93
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run Python Tests on LambdaTest Cloud Grid

Execute automation tests with Contexts on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)