本文整理汇总了Python中tactic_client_lib.TacticServerStub.eval方法的典型用法代码示例。如果您正苦于以下问题:Python TacticServerStub.eval方法的具体用法?Python TacticServerStub.eval怎么用?Python TacticServerStub.eval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tactic_client_lib.TacticServerStub
的用法示例。
在下文中一共展示了TacticServerStub.eval方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from tactic_client_lib import TacticServerStub [as 别名]
# 或者: from tactic_client_lib.TacticServerStub import eval [as 别名]
def main(testing_flag):
config = ConfigParser.ConfigParser()
config.read("config.ini")
# Get credentials from config file
user = config.get("credentials", "user")
password = config.get("credentials", "password")
project = config.get("credentials", "project")
# If the testing flag is passed, use the test server, otherwise use the live server
if testing_flag:
url = config.get("server", "test")
else:
url = config.get("server", "live")
# Get a server object to perform queries
server = TacticServerStub(server=url, project=project, user=user, password=password)
# Get titles marked as 'hot' items
hot_titles = server.eval("@SOBJECT(twog/title['bigboard', 'True']['status', '!=', 'Completed'])")
# Iterate through the titles, getting the client code and platform for each one
for title in hot_titles:
client_code = title.get("client_code")
platform_name = title.get("platform")
# Unfortunately, Titles hold the platform name, not the code, so a query has to be done to get that
platform_code_search = server.eval("@SOBJECT(twog/platform['name', '{0}'])".format(platform_name))
# This search returns a list (since multiple matches by 'name' is possible). Since this is just a quick, dirty
# script to insert some example connections, we will take only the first result and ignore the rest.
if platform_code_search:
platform_code = platform_code_search[0].get("code")
else:
continue
existing_connection_search = server.eval(
"@SOBJECT(twog/client_platform['client_code', '{0}']['platform_code', '{1}'])".format(
client_code, platform_code
)
)
if not existing_connection_search:
client_name_search = server.eval("@SOBJECT(twog/client['code', '{0}'])".format(client_code))
if client_name_search:
client_name = client_name_search[0].get("name")
# Finally, insert the entry into the twog/client_platform table.
server.insert(
"twog/client_platform",
{
"client_code": client_code,
"platform_code": platform_code,
"name": "{0} to {1}".format(client_name, platform_name),
"connection_status": "disconnected",
},
)
示例2: get_element_eval_from_tactic_one
# 需要导入模块: from tactic_client_lib import TacticServerStub [as 别名]
# 或者: from tactic_client_lib.TacticServerStub import eval [as 别名]
def get_element_eval_from_tactic_one(element_eval_code, username, password):
server = TacticServerStub(server='http://tactic01.2gdigital.com', project='twog', user=username,
password=password)
element_eval = server.eval("@SOBJECT(twog/element_eval['code', '{0}'])".format(element_eval_code))
element_eval_lines = server.eval("@SOBJECT(twog/element_eval_lines['element_eval_code', '{0}'])".format(element_eval_code))
element_eval_audio_lines = server.eval("@SOBJECT(twog/element_eval_audio['element_eval_code', '{0}'])".format(element_eval_code))
print(element_eval)
print(element_eval_lines)
print(element_eval_audio_lines)
示例3: main
# 需要导入模块: from tactic_client_lib import TacticServerStub [as 别名]
# 或者: from tactic_client_lib.TacticServerStub import eval [as 别名]
def main(testing_flag):
config = ConfigParser.ConfigParser()
config.read('config.ini')
# Get credentials from config file
user = config.get('credentials', 'user')
password = config.get('credentials', 'password')
project = config.get('credentials', 'project')
# If the testing flag is passed, use the test server, otherwise use the live server
if testing_flag:
url = config.get('server', 'test')
else:
url = config.get('server', 'live')
# Get a server object to perform queries
server = TacticServerStub(server=url, project=project, user=user, password=password)
territories_str = 'Afghanistan|Aland Islands|Albania|Algeria|American Samoa|Andorra|Angola|Anguilla|Antigua and Barbuda|Argentina|Armenia|Aruba|Australia|Austria|Azerbaijan|Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bermuda|Bhutan|Bolivia|Bonaire|Bosnia and Herzegovina|Botswana|Bouvet Island|Brazil|Brunei Darussalam|Bulgaria|Burkina Faso|Burundi|Cambodia|Cameroon|Canada|Cantonese|Cape Verde|Cayman Islands|Central African Republic|Chad|Chile|China|Christmas Island|Cocos Islands|Colombia|Comoros|Congo|Dem. Rep. of Congo|Cook Islands|Costa Rica|Croatia|Cuba|Curacao|Cyprus|Czech|Denmark|Djibouti|Dominica|Dominican Republic|Ecuador|Egypt|El Salvador|English|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Falkland Islands|Faroe Islands|Fiji|Finland|France|French Guiana|French Polynesia|Gabon|Gambia|Georgia|Germany|Ghana|Gibraltar|Greece|Greek|Greenland|Grenada|Guadeloupe|Guam|Guatemala|Guernsey|Guinea|Guinea-Bissau|Guyana|Haiti|Honduras|Hong Kong|Hungary|Iceland|India|Indonesia|Iran|Iraq|Ireland|Isle of Man|Israel|Italy|Ivory Coast|Jamaica|Japan|Jersey|Jordan|Kazakhstan|Kenya|Kiribati|Kuwait|Kyrgyztan|Laos|Latin America|Latin Spanish|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luzembourg|Macao|Macedonia|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Marshall Islands|Martinique|Mauritania|Mauritius|Mayotte|Mexico|Micronesia|Moldova|Monaco|Mongolia|Montenegro|Montserrat|Morocco|Mozambique|Multi-language|Myanmar|Namibia|Nauru|Nepal|Netherlands|New Caledonia|New Zealand|Nicaragua|Niger|Nigeria|Niue|Norfolk Island|North Korea|Northern Mariana Islands|Norway|Oman|Pakistan|Palau|Palestine|Panama|Papua New Guinea|Pan-Asia|Paraguay|Peru|Philippines|Pitcairn|Poland|Portugal|Puerto Rico|Qatar|Reunion|Romania|Russia|Russian|Rwanda|St Barthelemy|St Helena|St Kitts and Nevis|St Lucia|St Martin|St Pierre and Miquelo|St Vincent and Grenadines|Samoa|San Marino|Sao Tome and Principe|Saudi Arabia|Senegal|Serbia|Seychelles|Sierra Leone|Signapore|Sint Maarten|Slovakia|Slovenia|Solomon Islands|Somalia|South Africa|South Georgia and Swch Islands|South Korea|South Sudan|Spain|Sri Lanka|Sudan|Suriname|Svalbard|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thai|Thailand|Timor-Leste|Togo|Tokelau|Tonga|Trinidad and Tobago|Tunisia|Turkey|Turkmenistan|Turks and Caicos Islands|Tuvalu|Uganda|Ukraine|UAE|United Kingdom|United States|Uruguay|Uzbekistan|Vanuatu|Various|Vatican|Venezuela|Vietnam|Virgin Islands|Wallis and Futuna|West Indies|Western Sahara|Yemen|Zambia|Zimbabwe'
territories = territories_str.split('|')
for territory in territories:
territory_search = server.eval("@SOBJECT(twog/territory['name', '{0}'])".format(territory))
if not territory_search:
# Territory does not exist yet, insert it
server.insert('twog/territory', {'name': territory})
示例4: get
# 需要导入模块: from tactic_client_lib import TacticServerStub [as 别名]
# 或者: from tactic_client_lib.TacticServerStub import eval [as 别名]
def get(self):
parser = reqparse.RequestParser()
parser.add_argument('token', required=True)
args = parser.parse_args()
ticket = args.get('token')
server = TacticServerStub(server=url, project=project, ticket=ticket)
element_evaluations = server.eval("@SOBJECT(twog/element_evaluation)")
return jsonify({'element_evaluations': element_evaluations})
示例5: ExpressionApiTest
# 需要导入模块: from tactic_client_lib import TacticServerStub [as 别名]
# 或者: from tactic_client_lib.TacticServerStub import eval [as 别名]
class ExpressionApiTest(unittest.TestCase):
def setUp(self):
pass
def test_all(self):
self.server = TacticServerStub()
project_code = "unittest"
self.server.set_project(project_code)
self.server.start("Expression Test")
try:
self._setup()
self._test_expression()
except:
self.server.abort()
raise
else:
self.server.abort()
def _setup(self):
city_data = {
'code': 'los_angeles'
}
search_type = "unittest/person"
self.persons = []
for i in range(0,4):
data = {
'name_first': 'person%s' % i,
'name_last': 'Test',
'city_code': 'los_angeles',
'age': '25'
}
person = self.server.insert(search_type, data)
self.persons.append( person )
def _test_expression(self):
# get the people sobjects
expr = "@SOBJECT(unittest/person)"
result = self.server.eval(expr)
self.assertEquals(4, len(result))
self.assertEquals("los_angeles", result[0].get("city_code") )
# get a single person
expr = "@SOBJECT(unittest/person)"
result = self.server.eval(expr, single=True)
self.assertEquals("los_angeles", result.get('city_code'))
# get the first_name
expr = "@GET(unittest/person.name_first)"
names = self.server.eval(expr)
self.assertEquals(len(names), 4)
#self.assertEquals("person0", names[0])
#self.assertEquals("person1", names[1])
# count the number of people
expr = "@COUNT(unittest/person)"
count = self.server.eval(expr)
self.assertEquals(4, count)
# get the age of a person
expr = "@GET(unittest/person.age)"
age = self.server.eval(expr, self.persons[0], single=True)
self.assertEquals(25, age)
return