Пример #1
0
def main():
    mustache = {
      'accounts': [],
      'networth': sanatize(tail(runledger(commands['networth'])).replace("Assets", "")),
      'liquidity': sanatize(tail(runledger(commands['liquidity'])).replace("Assets", "")),
      'cashflow': sanatize(tail(runledger(commands['cashflow'])))
    }

    pie.main("./build/", ['-f', LEDGER_FILE, 'balance', '--basis', config.get(user, 'expenses_acct')])
    boxplot.main("./build/", ['-f', LEDGER_FILE])
    if(config.getboolean(user, 'budget')):
        mustache['budget'] = runledger(commands['budget'])

    output = runledger(commands['accts'])
    accts = []
    for line in output.split('\n'):
        line = line.split()
        accts += line[-1:]

    for acct in accts:
        if(len([ex for ex in exclude['acct'] if (acct.find(ex) != -1)]) > 0): continue

        account_data = {
          'name': unicode(acct),
          'retrospectives': retrospective(acct)
        }

        if(config.getboolean(user, 'budget')):
          account_data['forecasts'] = forecast(acct)

        mustache['accounts'].append(account_data)

    template_file = codecs.open(config.get(user, 'template_file'), encoding='utf-8', mode='r')
    template_data = "".join(template_file.readlines())
    template_file.close()
    tex_file = codecs.open('build/pdfledger.tex', encoding='utf-8', mode='w')
    tex_file.write(pystache.render(template_data, mustache))
    tex_file.close()
Пример #2
0
                # otherwise, we need to activate and run pie again, within the venv
                if pv.exists():
                    return pv.run_pie(args)
                else:
                    print('{} not found. You can create it with the -R argument.'.format(pv.PIE_VENV), file=sys.stderr)
                    return 1

        # try to execute each arg
        for a in parsed_args:
            try:
                a.execute()
            except CmdContextManager.CmdError as e:
                print('Error when executing command "{}". Errorcode = {}'.format(e.cmd, e.errorcode), file=sys.stderr)
                return e.errorcode
            except TaskCall.TaskNotFound as e:
                print('Task {} could not be found.'.format(e.name), file=sys.stderr)
                return 1
        return 0

    else:
        Help().execute()
        return 1


if __name__ == '__main__':
    # import pie so that both we and any pie_tasks code that imports pie are referring to the same module variables
    import pie

    # skip the name of the command
    sys.exit(pie.main(sys.argv[1:]))
Пример #3
0
import parse_json
import pie  #for generating pie chat
from docx import Document
from docx.shared import Inches

file = 'demo registratio failed.postman_test_run.json'
#file = 'demo registratio pass.postman_test_run.json'
input_for_chart = parse_json.parse(file)
pie.main(input_for_chart, file)

document = Document(file + '_report.docx')
p = document.add_paragraph()
r = p.add_run()
r.add_picture('chart.jpg', width=Inches(5.8))
document.add_paragraph(
    'Inner and outer circle represents requests and test results respectively')
document.save(file + '_report.docx')
Пример #4
0
                    else:
                        print('An error occurred when importing pie_tasks:\n'+traceback.format_exc())
                    return 1

            else:
                # otherwise, we need to activate and run pie again, within the venv
                if pv.exists():
                    return pv.run_pie(args)
                else:
                    print('{} not found. You can create it with the -R argument.'.format(pv.PIE_VENV))
                    return 1

        # try to execute each arg
        for a in parsed_args:
            try:
                a.execute()
            except TaskCall.TaskNotFound as e:
                print('Task {} could not be found.'.format(e.name))
                break

    else:
        Help().execute()



if __name__=='__main__':
    # import pie so that both we and any pie_tasks code that imports pie are referring to the same module variables
    import pie
    # skip the name of the command
    sys.exit(pie.main(sys.argv[1:]))
Пример #5
0
        tasksImported=False
        for a in args:
            # only import tasks if needed, saves exceptions when only looking for help or creating the batch file
            if a.needsTasksImported and not tasksImported:
                try:
                    importTasks()
                except Exception as e:
                    # pick up the specific case of not being able to find a pie_tasks module/package
                    if isinstance(e,ImportError) and e.message=='No module named pie_tasks':
                        print('pie_tasks could not be found.')
                    else:
                        print('An error occurred when importing pie_tasks:\n'+traceback.format_exc())
                    break
                tasksImported=True
            # try to execute the arg
            try:
                a.execute()
            except TaskCall.TaskNotFound as e:
                print('Task {} could not be found.'.format(e.name))
                break
            # print(repr(a))
    else:
        Help().execute()


if __name__=='__main__':
    # import pie so that both we and any pie_tasks code that imports pie are referring to the same module variables
    import pie
    # skip the name of the command
    pie.main(sys.argv[1:])