1 | #!/usr/bin/env python |
||
2 | # -*- coding: utf-8 -*- |
||
3 | |||
4 | import logging |
||
5 | import os |
||
6 | logger = logging.getLogger(__name__) |
||
7 | logger.debug("%s loaded", __name__) |
||
8 | |||
9 | DOORPI_SECTION = 'DoorPi' |
||
10 | |||
11 | def get(*args, **kwargs): |
||
0 ignored issues
–
show
Unused Code
introduced
by
Loading history...
|
|||
12 | files = dict() |
||
13 | try: |
||
14 | if len(kwargs['name']) == 0: kwargs['name'] = [''] |
||
15 | if len(kwargs['value']) == 0: kwargs['value'] = [''] |
||
16 | |||
17 | path = kwargs['DoorPiObject'].config.get_string_parsed(DOORPI_SECTION, 'snapshot_path') |
||
18 | if os.path.exists(path): |
||
19 | files = [os.path.join(path,i) for i in os.listdir(path)] |
||
20 | files = sorted(files, key=os.path.getmtime) |
||
21 | # because path is added by webserver automatically |
||
22 | if path.find('DoorPiWeb'): |
||
23 | changedpath = path[path.find('DoorPiWeb')+len('DoorPiWeb'):] |
||
24 | files = [f.replace(path, changedpath) for f in files] |
||
25 | return files |
||
26 | except Exception as exp: |
||
27 | logger.exception(exp) |
||
28 | return {'Error': 'could not create '+str(__name__)+' object - '+str(exp)} |
||
29 |