548
550
submission_options
553
def _prepare_transports(self):
554
self._available_transports = get_all_transports()
555
self.transports = dict()
558
def get_certification_transport_config(self):
559
"""Returns the c3 (certification) transport configuration."""
560
for report in self.launcher.stock_reports:
561
self._prepare_stock_report(report)
562
if 'c3' in self.launcher.transports:
563
return self.launcher.transports['c3']
564
elif 'c3-staging' in self.launcher.transports:
565
return self.launcher.transports['c3-staging']
569
def export_results_with_launcher_settings(self):
571
Export results to file(s) in the user's 'Documents' directory.
572
This method follows the launcher reports configuration.
574
self.assistant.finalize_session()
575
for report in self.launcher.stock_reports:
576
self._prepare_stock_report(report)
577
# reports are stored in an ordinary dict(), so sorting them ensures
578
# the same order of submitting them between runs.
580
for name, params in sorted(self.launcher.reports.items()):
581
exporter_id = self.launcher.exporters[params['exporter']]['unit']
582
if self.launcher.transports[params['transport']]['type'] == 'file':
583
path = self.launcher.transports[params['transport']]['path']
584
cls = self._available_transports['file']
585
self.transports[params['transport']] = cls(path)
586
transport = self.transports[params['transport']]
587
result = self.assistant.export_to_transport(
588
exporter_id, transport)
590
result and 'url' in result and
591
result['url'].endswith('html')
593
html_url = result['url']
596
def _prepare_stock_report(self, report):
597
# this is purposefully not using pythonic dict-keying for better
599
if not self.launcher.transports:
600
self.launcher.transports = dict()
601
if not self.launcher.exporters:
602
self.launcher.exporters = dict()
603
if not self.launcher.reports:
604
self.launcher.reports = dict()
605
if report == 'certification':
606
self.launcher.exporters['hexr'] = {
607
'unit': '2013.com.canonical.plainbox::hexr'}
608
self.launcher.transports['c3'] = {
609
'type': 'certification',
610
'secure_id': self.launcher.transports.get('c3', {}).get(
612
self.launcher.reports['upload to certification'] = {
613
'transport': 'c3', 'exporter': 'hexr'}
614
elif report == 'certification-staging':
615
self.launcher.exporters['hexr'] = {
616
'unit': '2013.com.canonical.plainbox::hexr'}
617
self.launcher.transports['c3-staging'] = {
618
'type': 'certification',
619
'secure_id': self.launcher.transports.get('c3', {}).get(
622
self.launcher.reports['upload to certification-staging'] = {
623
'transport': 'c3-staging', 'exporter': 'hexr'}
624
elif report == 'submission_files':
625
timestamp = datetime.datetime.utcnow().isoformat()
626
base_dir = self._get_user_directory_documents()
627
for exporter, file_ext in [('hexr', '.xml'), ('html', '.html'),
628
('xlsx', '.xlsx'), ('tar', '.tar.xz')]:
629
path = os.path.join(base_dir, ''.join(
630
['submission_', timestamp, file_ext]))
631
self.launcher.transports['{}_file'.format(exporter)] = {
634
self.launcher.exporters[exporter] = {
635
'unit': '2013.com.canonical.plainbox::{}'.format(exporter)}
636
self.launcher.reports['2_{}_file'.format(exporter)] = {
637
'transport': '{}_file'.format(exporter),
638
'exporter': '{}'.format(exporter)
552
642
def drop_permissions(self, app_id, services):
553
643
# TODO: use XDG once available