本文整理匯總了Python中weblab.data.experiments.ExperimentUsage.start_date方法的典型用法代碼示例。如果您正苦於以下問題:Python ExperimentUsage.start_date方法的具體用法?Python ExperimentUsage.start_date怎麽用?Python ExperimentUsage.start_date使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weblab.data.experiments.ExperimentUsage
的用法示例。
在下文中一共展示了ExperimentUsage.start_date方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_usage
# 需要導入模塊: from weblab.data.experiments import ExperimentUsage [as 別名]
# 或者: from weblab.data.experiments.ExperimentUsage import start_date [as 別名]
def create_usage(gateway, reservation_id = 'my_reservation_id'):
session = gateway.Session()
try:
student1 = gateway._get_user(session, 'student1')
initial_usage = ExperimentUsage()
initial_usage.start_date = time.time()
initial_usage.end_date = time.time()
initial_usage.from_ip = "130.206.138.16"
initial_usage.experiment_id = ExperimentId("ud-dummy","Dummy experiments")
initial_usage.coord_address = CoordAddress("machine1","instance1","server1")
initial_usage.reservation_id = reservation_id
file1 = FileSent(
'path/to/file1',
'{sha}12345',
time.time()
)
file2 = FileSent(
'path/to/file2',
'{sha}123456',
time.time(),
Command.Command('response'),
time.time(),
file_info = 'program'
)
command1 = CommandSent(
Command.Command("your command1"),
time.time()
)
command2 = CommandSent(
Command.Command("your command2"),
time.time(),
Command.Command("your response2"),
time.time()
)
initial_usage.append_command(command1)
initial_usage.append_command(command2)
initial_usage.append_file(file1)
initial_usage.append_file(file2)
initial_usage.request_info = {'facebook' : False, 'permission_scope' : 'user', 'permission_id' : student1.id}
gateway.store_experiment_usage(student1.login, initial_usage)
return student1, initial_usage, command1, command2, file1, file2
finally:
session.close()
示例2: to_business_light
# 需要導入模塊: from weblab.data.experiments import ExperimentUsage [as 別名]
# 或者: from weblab.data.experiments.ExperimentUsage import start_date [as 別名]
def to_business_light(self):
usage = ExperimentUsage()
usage.experiment_use_id = self.id
usage.start_date = _splitted_utc_datetime_to_timestamp(self.start_date, self.start_date_micro)
usage.end_date = _splitted_utc_datetime_to_timestamp(self.end_date, self.end_date_micro)
usage.from_ip = self.origin
usage.reservation_id = self.reservation_id
usage.experiment_id = ExperimentId(self.experiment.name, self.experiment.category.name)
usage.coord_address = CoordAddress.translate(self.coord_address)
request_info = {}
for prop in self.properties:
name = prop.property_name.name
value = prop.value
request_info[name] = value
usage.request_info = request_info
return usage
示例3: test_update_command
# 需要導入模塊: from weblab.data.experiments import ExperimentUsage [as 別名]
# 或者: from weblab.data.experiments.ExperimentUsage import start_date [as 別名]
def test_update_command(self):
session = self.gateway.Session()
student1 = self.gateway._get_user(session, 'student1')
RESERVATION_ID1 = 'my_reservation_id1'
usage1 = ExperimentUsage()
usage1.start_date = time.time()
usage1.end_date = time.time()
usage1.from_ip = "130.206.138.16"
usage1.experiment_id = ExperimentId("ud-dummy","Dummy experiments")
usage1.coord_address = CoordAddress.CoordAddress("machine1","instance1","server1") #.translate_address("server1:[email protected]")
usage1.reservation_id = RESERVATION_ID1
usage1.request_info = {'facebook' : False}
self.gateway.store_experiment_usage(student1.login, usage1)
usages = self.gateway.list_usages_per_user(student1.login)
self.assertEquals(1, len(usages))
full_usage = self.gateway.retrieve_usage(usages[0].experiment_use_id)
self.assertEquals(0, len(full_usage.commands))
command1 = CommandSent( Command.Command("your command"), time.time() )
command_id = self.gateway.append_command( RESERVATION_ID1, command1 )
full_usage = self.gateway.retrieve_usage(usages[0].experiment_use_id)
self.assertEquals("your command", full_usage.commands[0].command.commandstring)
self.assertEquals(Command.NullCommand(), full_usage.commands[0].response)
self.gateway.update_command(command_id, Command.Command("the response"), time.time())
full_usage = self.gateway.retrieve_usage(usages[0].experiment_use_id)
self.assertEquals("your command", full_usage.commands[0].command.commandstring)
self.assertEquals("the response", full_usage.commands[0].response.commandstring)
示例4: test_update_file
# 需要導入模塊: from weblab.data.experiments import ExperimentUsage [as 別名]
# 或者: from weblab.data.experiments.ExperimentUsage import start_date [as 別名]
def test_update_file(self):
session = self.gateway.Session()
student1 = self.gateway._get_user(session, 'student1')
RESERVATION_ID1 = 'my_reservation_id1'
RESERVATION_ID2 = 'my_reservation_id2'
usage1 = ExperimentUsage()
usage1.start_date = time.time()
usage1.end_date = time.time()
usage1.from_ip = "130.206.138.16"
usage1.experiment_id = ExperimentId("ud-dummy","Dummy experiments")
usage1.coord_address = CoordAddress.CoordAddress("machine1","instance1","server1") #.translate_address("server1:[email protected]")
usage1.reservation_id = RESERVATION_ID1
usage1.request_info = {'facebook' : False}
usage2 = ExperimentUsage()
usage2.start_date = time.time()
usage2.end_date = time.time()
usage2.from_ip = "130.206.138.17"
usage2.experiment_id = ExperimentId("ud-dummy","Dummy experiments")
usage2.coord_address = CoordAddress.CoordAddress("machine1","instance1","server1") #.translate_address("server1:[email protected]")
usage2.reservation_id = RESERVATION_ID2
usage2.request_info = {'facebook' : False}
self.gateway.store_experiment_usage(student1.login, usage1)
self.gateway.store_experiment_usage(student1.login, usage2)
file_sent1 = FileSent(
'path/to/file2',
'{sha}123456',
time.time(),
file_info = 'program'
)
usages = self.gateway.list_usages_per_user(student1.login)
self.assertEquals(2, len(usages))
full_usage1 = self.gateway.retrieve_usage(usages[0].experiment_use_id)
full_usage2 = self.gateway.retrieve_usage(usages[1].experiment_use_id)
self.assertEquals(0, len(full_usage1.commands))
self.assertEquals(0, len(full_usage2.commands))
self.assertEquals(0, len(full_usage1.sent_files))
self.assertEquals(0, len(full_usage2.sent_files))
file_sent_id = self.gateway.append_file(RESERVATION_ID1, file_sent1)
full_usage1 = self.gateway.retrieve_usage(usages[0].experiment_use_id)
full_usage2 = self.gateway.retrieve_usage(usages[1].experiment_use_id)
self.assertEquals(0, len(full_usage1.commands))
self.assertEquals(0, len(full_usage2.commands))
self.assertEquals(1, len(full_usage1.sent_files))
self.assertEquals(0, len(full_usage2.sent_files))
self.assertEquals(None, full_usage1.sent_files[0].response.commandstring)
self.gateway.update_file(file_sent_id, Command.Command("response"), time.time())
full_usage1 = self.gateway.retrieve_usage(usages[0].experiment_use_id)
full_usage2 = self.gateway.retrieve_usage(usages[1].experiment_use_id)
self.assertEquals(0, len(full_usage1.commands))
self.assertEquals(0, len(full_usage2.commands))
self.assertEquals(1, len(full_usage1.sent_files))
self.assertEquals(0, len(full_usage2.sent_files))
self.assertEquals("response", full_usage1.sent_files[0].response.commandstring)
示例5: test_finish_experiment_usage
# 需要導入模塊: from weblab.data.experiments import ExperimentUsage [as 別名]
# 或者: from weblab.data.experiments.ExperimentUsage import start_date [as 別名]
def test_finish_experiment_usage(self):
session = self.gateway.Session()
student1 = self.gateway._get_user(session, 'student1')
RESERVATION_ID1 = 'my_reservation_id1'
RESERVATION_ID2 = 'my_reservation_id2'
usage1 = ExperimentUsage()
usage1.start_date = time.time()
usage1.from_ip = "130.206.138.16"
usage1.experiment_id = ExperimentId("ud-dummy","Dummy experiments")
usage1.coord_address = CoordAddress.CoordAddress("machine1","instance1","server1") #.translate_address("server1:[email protected]")
usage1.reservation_id = RESERVATION_ID1
command1 = CommandSent(
Command.Command("your command1"),
time.time(),
Command.Command("your response1"),
time.time()
)
usage1.append_command(command1)
usage1.request_info = {'facebook' : False}
usage2 = ExperimentUsage()
usage2.start_date = time.time()
usage2.from_ip = "130.206.138.17"
usage2.experiment_id = ExperimentId("ud-dummy","Dummy experiments")
usage2.coord_address = CoordAddress.CoordAddress("machine1","instance1","server1") #.translate_address("server1:[email protected]")
usage2.reservation_id = RESERVATION_ID2
command2 = CommandSent(
Command.Command("your command2"),
time.time(),
Command.Command("your response2"),
time.time()
)
usage2.append_command(command2)
usage2.request_info = {'facebook' : False}
self.gateway.store_experiment_usage(student1.login, usage1)
self.gateway.store_experiment_usage(student1.login, usage2)
finishing_command = CommandSent(
Command.Command("@@@[email protected]@@"),
time.time(),
Command.Command("finish"),
time.time()
)
usages = self.gateway.list_usages_per_user(student1.login)
self.assertEquals(2, len(usages))
full_usage1 = self.gateway.retrieve_usage(usages[0].experiment_use_id)
full_usage2 = self.gateway.retrieve_usage(usages[1].experiment_use_id)
self.assertEquals(None, full_usage1.end_date)
self.assertEquals(None, full_usage2.end_date)
self.assertEquals(1, len(full_usage1.commands))
self.assertEquals(1, len(full_usage2.commands))
result = self.gateway.finish_experiment_usage(RESERVATION_ID1, time.time(), finishing_command)
self.assertTrue(result)
full_usage1 = self.gateway.retrieve_usage(usages[0].experiment_use_id)
full_usage2 = self.gateway.retrieve_usage(usages[1].experiment_use_id)
self.assertNotEqual(None, full_usage1.end_date)
self.assertEquals(None, full_usage2.end_date)
self.assertEquals(2, len(full_usage1.commands))
self.assertEquals(1, len(full_usage2.commands))
self.assertEquals("@@@[email protected]@@", full_usage1.commands[1].command.commandstring)
self.assertEquals("finish", full_usage1.commands[1].response.commandstring)
示例6: _store_two_reservations
# 需要導入模塊: from weblab.data.experiments import ExperimentUsage [as 別名]
# 或者: from weblab.data.experiments.ExperimentUsage import start_date [as 別名]
def _store_two_reservations(self):
#
# Two users: student2, that started before "any" but finished after "any", and "any" then. Both use
# the same experiment.
#
db_gw = self.ups._db_manager
session = db_gw.Session()
try:
student1 = db_gw._get_user(session, 'student1')
student2 = db_gw._get_user(session, 'student2')
finally:
session.close()
reservation_id1 = SessionId.SessionId(u'5')
initial_usage1 = ExperimentUsage()
initial_usage1.start_date = time.time()
initial_usage1.end_date = time.time()
initial_usage1.from_ip = u"130.206.138.16"
initial_usage1.experiment_id = ExperimentId(u"ud-dummy",u"Dummy experiments")
initial_usage1.coord_address = CoordAddress(u"machine1",u"instance1",u"server1")
initial_usage1.reservation_id = reservation_id1.id
initial_usage1.request_info = { 'permission_scope' : 'user', 'permission_id' : student1.id }
valid_file_path = os.path.relpath(os.sep.join(('test','__init__.py')))
file1 = FileSent( valid_file_path, u'{sha}12345', time.time())
file2 = FileSent( valid_file_path, u'{sha}123456',
time.time(), Command(u'response'),
time.time(), file_info = u'program')
command1 = CommandSent( Command(u"your command1"), time.time())
command2 = CommandSent( Command(u"your command2"), time.time(),
Command(u"your response2"), time.time())
initial_usage1.append_command(command1)
initial_usage1.append_command(command2)
initial_usage1.append_file(file1)
initial_usage1.append_file(file2)
reservation_id2 = SessionId.SessionId(u'6')
initial_usage2 = ExperimentUsage()
initial_usage2.start_date = time.time()
initial_usage2.end_date = time.time()
initial_usage2.from_ip = u"130.206.138.16"
initial_usage2.experiment_id = ExperimentId(u"ud-dummy",u"Dummy experiments")
initial_usage2.coord_address = CoordAddress(u"machine1",u"instance1",u"server1")
initial_usage2.reservation_id = reservation_id2.id
initial_usage2.request_info = { 'permission_scope' : 'user', 'permission_id' : student2.id }
file1 = FileSent( valid_file_path, u'{sha}12345', time.time())
file2 = FileSent( valid_file_path, u'{sha}123456',
time.time(), Command(u'response'),
time.time(), file_info = u'program')
command1 = CommandSent( Command(u"your command1"), time.time())
command2 = CommandSent( Command(u"your command2"), time.time(),
Command(u"your response2"), time.time())
initial_usage2.append_command(command1)
initial_usage2.append_command(command2)
initial_usage2.append_file(file1)
initial_usage2.append_file(file2)
self.ups._db_manager.store_experiment_usage('student1', initial_usage1)
self.ups._db_manager.store_experiment_usage('student2', initial_usage2)
return (reservation_id1, reservation_id2), (initial_usage1, initial_usage2)
示例7: test_add_file
# 需要導入模塊: from weblab.data.experiments import ExperimentUsage [as 別名]
# 或者: from weblab.data.experiments.ExperimentUsage import start_date [as 別名]
def test_add_file(self):
student1 = self.gateway._get_user(self.session, 'student1')
RESERVATION_ID1 = 'my_reservation_id1'
RESERVATION_ID2 = 'my_reservation_id2'
usage1 = ExperimentUsage()
usage1.start_date = time.time()
usage1.end_date = time.time()
usage1.from_ip = "130.206.138.16"
usage1.experiment_id = ExperimentId("ud-dummy","Dummy experiments")
usage1.coord_address = CoordAddress("machine1","instance1","server1")
usage1.reservation_id = RESERVATION_ID1
command1 = CommandSent(
Command.Command("your command1"),
time.time(),
Command.Command("your response1"),
time.time()
)
usage1.append_command(command1)
usage1.request_info = {'facebook' : False, 'permission_scope' : 'user', 'permission_id' : student1.id}
usage2 = ExperimentUsage()
usage2.start_date = time.time()
usage2.end_date = time.time()
usage2.from_ip = "130.206.138.17"
usage2.experiment_id = ExperimentId("ud-dummy","Dummy experiments")
usage2.coord_address = CoordAddress("machine1","instance1","server1")
usage2.reservation_id = RESERVATION_ID2
command2 = CommandSent(
Command.Command("your command2"),
time.time(),
Command.Command("your response2"),
time.time()
)
usage2.append_command(command2)
usage2.request_info = {'facebook' : False, 'permission_scope' : 'user', 'permission_id' : student1.id}
self.gateway.store_experiment_usage(student1.login, usage1)
self.gateway.store_experiment_usage(student1.login, usage2)
file_sent1 = FileSent(
'path/to/file2',
'{sha}123456',
time.time(),
Command.Command('response'),
time.time(),
file_info = 'program'
)
usages = self.gateway.list_usages_per_user(student1.login)
self.assertEquals(2, len(usages))
full_usage1 = self.gateway.retrieve_usage(usages[0].experiment_use_id)
full_usage2 = self.gateway.retrieve_usage(usages[1].experiment_use_id)
self.assertEquals(1, len(full_usage1.commands))
self.assertEquals(1, len(full_usage2.commands))
self.assertEquals(0, len(full_usage1.sent_files))
self.assertEquals(0, len(full_usage2.sent_files))
self.gateway.append_file(RESERVATION_ID1, file_sent1)
full_usage1 = self.gateway.retrieve_usage(usages[0].experiment_use_id)
full_usage2 = self.gateway.retrieve_usage(usages[1].experiment_use_id)
self.assertEquals(1, len(full_usage1.commands))
self.assertEquals(1, len(full_usage2.commands))
self.assertEquals(1, len(full_usage1.sent_files))
self.assertEquals(0, len(full_usage2.sent_files))
self.assertEquals("response", full_usage1.sent_files[0].response.commandstring)