本文整理匯總了Python中vistrails.core.vistrail.controller.VistrailController.changed方法的典型用法代碼示例。如果您正苦於以下問題:Python VistrailController.changed方法的具體用法?Python VistrailController.changed怎麽用?Python VistrailController.changed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vistrails.core.vistrail.controller.VistrailController
的用法示例。
在下文中一共展示了VistrailController.changed方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: push_vistrail_to_repository
# 需要導入模塊: from vistrails.core.vistrail.controller import VistrailController [as 別名]
# 或者: from vistrails.core.vistrail.controller.VistrailController import changed [as 別名]
def push_vistrail_to_repository(self, branching=False):
""" uploads current VisTrail to web repository """
self._repository_status['details'] = "Pushing to repository..."
self._push_button.setEnabled(False)
self._branch_button.setEnabled(False)
self.update_push_information()
try:
# create temp file
(fd, filename) = tempfile.mkstemp(suffix='.vt', prefix='vt_tmp')
os.close(fd)
# writing tmp vt and switching back to orginal vt
locator = ZIPFileLocator(filename)
controller = vistrails.api.get_current_controller()
tmp_controller = VistrailController(controller.vistrail.do_copy(),
locator)
tmp_controller.changed = True
tmp_controller.write_vistrail(locator)
# check if this vt is from the repository
if controller.vistrail.get_annotation('repository_vt_id'):
repository_vt_id = controller.vistrail.get_annotation('repository_vt_id').value
else:
repository_vt_id = -1
# upload vistrail temp file to repository
register_openers(cookiejar=self.dialog.cookiejar)
project = self.serverCombo.itemData(self.serverCombo.currentIndex())[0]
if project == "Default": project = ""
params = {'vistrail_file': open(filename, 'rb'),
'action': 'upload',
'name': controller.locator.short_name,
'repository_vt_id': repository_vt_id if not branching else -1,
'is_runnable': not bool(len(self.unsupported_packages)+ \
len(self.local_data_modules)),
'vt_id': 0,
'branched_from': "" if not branching else repository_vt_id,
'project': project,
'everyone_can_view': self.perm_view.checkState(),
'everyone_can_edit': self.perm_edit.checkState(),
'everyone_can_download': self.perm_download.checkState()
}
upload_url = "%s/vistrails/remote_upload/" % \
self.config.webRepositoryURL
datagen, headers = multipart_encode(params)
request = urllib2.Request(upload_url, datagen, headers)
result = urllib2.urlopen(request)
updated_response = result.read()
os.unlink(filename)
if updated_response[:6] == "upload":
# No update, just upload
if result.code != 200:
self._repository_status['details'] = \
"Push to repository failed"
debug.critical("Push to repository failed (Please contact an administrator)")
else:
repository_vt_id = int(updated_response[8:])
controller.vistrail.set_annotation('repository_vt_id',
repository_vt_id)
controller.vistrail.set_annotation('repository_creator',
self.dialog.loginUser)
# ensure that the annotations get saved
controller.set_changed(True)
self._repository_status['details'] = \
"Push to repository was successful"
else:
# update, load updated vistrail
if result.code != 200:
self._repository_status['details'] = "Update Failed"
debug.critical("Update vistrail in web repository failed (Please contact an administrator)")
else:
debug.log("getting version from web")
# request file to download
download_url = "%s/vistrails/download/%s/" % \
(self.config.webRepositoryURL, updated_response)
request = urllib2.Request(download_url)
result = urllib2.urlopen(request)
updated_file = result.read()
# create temp file of updated vistrail
(fd, updated_filename) = tempfile.mkstemp(suffix='.vtl',
prefix='vtl_tmp')
os.close(fd)
updated_vt = open(updated_filename, 'w')
updated_vt.write(updated_file)
updated_vt.close()
# switch vistrails to updated one
controller = vistrails.api.get_current_controller()
updated_locator = FileLocator(updated_filename)
(up_vistrail, abstractions, thumbnails, mashups) = \
#.........這裏部分代碼省略.........