You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

49 lines
1.4 KiB

# coding=utf-8
# Получить список файлов папки reports
# Выдать выбор отчета
# Запустить файл
import os
import sys
BASEDIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
REPORTS = '/var/www/projects/codemy/_utils/reports'
class CL:
def __init__(self):
print('# Система отчетов')
print('=======================')
print('Дирректория отчетов: {0}'.format(REPORTS))
self.files = self.get_files_list()
def get_files_list(self):
# Получение рабочих файлов дирректории
__tmp = []
for p, dir, files in os.walk(REPORTS):
for f in files:
if f.endswith('.py') and f != '__init__.py':
__tmp.append(os.path.join(p, f))
return __tmp
def choise_report(self):
# Выбрать отчет
print('Выберите отчет')
_n = 0
for _t in self.files:
print('{0}: {1}'.format(_n, _t))
_n += 1
_ch = input('Ваш выбор: ')
if _ch == '-':
sys.exit(0)
else:
os.system('python {0}'.format(os.path.join(REPORTS, self.files[int(_ch)])))
def main():
CL().choise_report()
print('========')
print('Работа закончена. Удачи.')
if __name__ == '__main__':
main()