comparison src/pages/files/view/page_meta.py @ 1113:cdd389ef97bc

server: code style reformatting using black
author Goffi <goffi@goffi.org>
date Fri, 29 Jun 2018 17:45:26 +0200
parents 2dab7692eae7
children
comparison
equal deleted inserted replaced
1112:f287fc8bb31a 1113:cdd389ef97bc
8 from libervia.server.utils import ProgressHandler 8 from libervia.server.utils import ProgressHandler
9 import tempfile 9 import tempfile
10 import os 10 import os
11 import os.path 11 import os.path
12 from sat.core.log import getLogger 12 from sat.core.log import getLogger
13 log = getLogger('pages/files/view') 13
14 log = getLogger("pages/files/view")
14 """files handling pages""" 15 """files handling pages"""
15 16
16 name = u'files_view' 17 name = u"files_view"
17 access = C.PAGES_ACCESS_PROFILE 18 access = C.PAGES_ACCESS_PROFILE
18 19
20
19 def parse_url(self, request): 21 def parse_url(self, request):
20 self.getPathArgs(request, ['service', '*path'], min_args=2, service='jid', path='') 22 self.getPathArgs(request, ["service", "*path"], min_args=2, service="jid", path="")
23
21 24
22 def cleanup(dummy, tmp_dir, dest_path): 25 def cleanup(dummy, tmp_dir, dest_path):
23 try: 26 try:
24 os.unlink(dest_path) 27 os.unlink(dest_path)
25 except OSError: 28 except OSError:
32 35
33 @defer.inlineCallbacks 36 @defer.inlineCallbacks
34 def render(self, request): 37 def render(self, request):
35 data = self.getRData(request) 38 data = self.getRData(request)
36 profile = self.getProfile(request) 39 profile = self.getProfile(request)
37 service, path_elts = data[u'service'], data[u'path'] 40 service, path_elts = data[u"service"], data[u"path"]
38 basename = path_elts[-1] 41 basename = path_elts[-1]
39 dir_elts = path_elts[:-1] 42 dir_elts = path_elts[:-1]
40 dir_path = u'/'.join(dir_elts) 43 dir_path = u"/".join(dir_elts)
41 tmp_dir = tempfile.mkdtemp() 44 tmp_dir = tempfile.mkdtemp()
42 dest_path = os.path.join(tmp_dir, basename) 45 dest_path = os.path.join(tmp_dir, basename)
43 request.notifyFinish().addCallback(cleanup, tmp_dir, dest_path) 46 request.notifyFinish().addCallback(cleanup, tmp_dir, dest_path)
44 progress_id = yield self.host.bridgeCall('fileJingleRequest', 47 progress_id = yield self.host.bridgeCall(
45 service.full(), 48 "fileJingleRequest",
46 dest_path, 49 service.full(),
47 basename, 50 dest_path,
48 u'', 51 basename,
49 u'', 52 u"",
50 {u'path': dir_path}, 53 u"",
51 profile) 54 {u"path": dir_path},
52 log.debug(u'file requested') 55 profile,
56 )
57 log.debug(u"file requested")
53 yield ProgressHandler(self.host, progress_id, profile).register() 58 yield ProgressHandler(self.host, progress_id, profile).register()
54 log.debug(u'file downloaded') 59 log.debug(u"file downloaded")
55 self.delegateToResource(request, static.File(dest_path)) 60 self.delegateToResource(request, static.File(dest_path))