def export_cmd(): """Export utilitiy tool, stream csv datas in stdout Usage: autonomie-export <config_uri> userdatas [--fields=<fields>] [--where=<where>] Options: -h --help Show this screen --fields=<fields> Export the comma separated list of fields --where=<where> Query parameters in json format o userdatas : Export userdatas as csv format Streams the output in stdout autonomie-export app.ini userdatas \ --fields=coordonnees_address,coordonnees_zipcode,coordonnees_city,\ coordonnees_sex,coordonnees_birthday,statut_social_status,\ coordonnees_study_level,parcours_date_info_coll,parcours_prescripteur,\ parcours_convention_cape,activity_typologie,sortie_date,sortie_motif \ --where='[{"key":"created_at","method":"dr","type":"date",\ "search1":"1999-01-01","search2":"2016-12-31"}]'\ > /tmp/toto.csv """ def callback(arguments, env): if arguments['userdatas']: func = _export_user_datas return func(arguments, env) try: return command(callback, export_cmd.__doc__) finally: pass
def autonomie_fake_cmd(): """Populate the database with fake datas Usage: autonomie-fake <config_uri> populate autonomie-fake <config_uri> populate_conf autonomie-fake <config_uri> anonymize [--method=<method>] o populate: Add sample datas o populate_conf: Add sample configuration datas o anonymize: Anonymize current database datas (method : name of the method to launch) Options: -h --help Show this screen. """ def callback(arguments, env): if arguments['populate']: func = fake_database_fill elif arguments['populate_conf']: func = set_configuration elif arguments['anonymize']: # Évite la dépendance à faker jusqu'à l'appel effectif from autonomie.scripts.anonymize import anonymize_database func = anonymize_database else: print autonomie_fake_cmd.__doc__ sys.exit(1) return func(arguments, env) try: return command(callback, autonomie_fake_cmd.__doc__) finally: pass
def autonomie_admin_cmd(): """Autonomie administration tool Usage: autonomie-admin <config_uri> useradd [--user=<user>] [--pwd=<password>] [--firstname=<firstname>] [--lastname=<lastname>] [--email=<email>] [--group=<group>] autonomie-admin <config_uri> testmail [--to=<mailadress>] autonomie-admin <config_uri> syncdb autonomie-admin <config_uri> resize_headers [--limit=<limit>] [--offset=<offset>] o useradd : Add a user in the database o testmail : Send a test mail to the given address o syncdb : Populate the database with the initial datas o resize_headers : bulk resize company header files to limit pdf size Options: -h --help Show this screen. """ def callback(arguments, env): if arguments['useradd']: func = user_add_command elif arguments['testmail']: func = test_mail_command elif arguments['syncdb']: func = syncdb_command elif arguments['resize_headers']: func = resize_headers_command return func(arguments, env) try: return command(callback, autonomie_admin_cmd.__doc__) finally: pass
def add_admin_cmd(): """Create an admin account in Autonomie Usage: autonomie-admin <config_uri> add [--user=<user>] [--pwd=<password>] [--firstname=<firstname>] [--lastname=<lastname>] [--email=<email>] Options: -h --help Show this screen. """ try: return command(add_admin, add_admin_cmd.__doc__) finally: pass
def populate_fake(): """Populate the database with fake datas Usage: autonomie-fake <config_uri> populate Options: -h --help Show this screen. """ try: return command(fake_database_fill, populate_fake.__doc__) finally: pass
def export_task_totals_cmd(): """Test migration of costs Usage: test-migration <config_uri> test [--f=<filename>] [--a=<action>] Options: -h --help Show this screen """ try: return command(export_task_totals, export_task_totals_cmd.__doc__) finally: pass
def mail_cmd(): """ Send the given file to the email address associated to the account having the good Usage: autonomie-mail <config_uri> mail --type=<filetype> --file=<filepath> [-f] Options: -h --help Show this screen """ try: return command(mail_it, mail_cmd.__doc__) finally: pass
def migrate(): """Migrate autonomie's database Usage: migrate <config_uri> list migrate <config_uri> upgrade [--rev=<rev>] migrate <config_uri> fetch [--rev=<rev>] migrate <config_uri> revision [--m=<message>] [--empty] migrate <config_uri> downgrade [--rev=<rev>] migrate <config_uri> merge [--rev1=<rev>] [--rev2=<rev>] o list : all the revisions o upgrade : upgrade the app to the latest revision o revision : create a migration file with the given message (trying to detect changes, unless --empty is used) o fetch : set the revision o downgrade : downgrade the database o merge : create a merge revision between two diverging revisions (you might ommit --rev*, they will get autodected) Options: -h --help Show this screen. """ def callback(arguments, env): args = () if arguments['list']: func = list_all elif arguments['upgrade']: args = (arguments['--rev'], ) func = upgrade elif arguments['fetch']: args = (arguments['--rev'], ) func = fetch elif arguments['revision']: args = (arguments['--m'], arguments['--empty']) func = revision elif arguments['downgrade']: args = (arguments['--rev'], ) func = downgrade elif arguments['merge']: args = (arguments['--rev1'], arguments['--rev2']) func = merge return func(*args) try: return command(callback, migrate.__doc__) except CommandError as e: if 'has multiple heads' in e.message: print(MULTIPLE_HEADS_MSG) exit(1) else: raise
def migrate(): """Migrate autonomie's database Usage: migrate <config_uri> list migrate <config_uri> upgrade [--rev=<rev>] migrate <config_uri> fetch [--rev=<rev>] migrate <config_uri> revision [--m=<message>] [--empty] migrate <config_uri> downgrade [--rev=<rev>] migrate <config_uri> merge [--rev1=<rev>] [--rev2=<rev>] o list : all the revisions o upgrade : upgrade the app to the latest revision o revision : create a migration file with the given message (trying to detect changes, unless --empty is used) o fetch : set the revision o downgrade : downgrade the database o merge : create a merge revision between two diverging revisions (you might ommit --rev*, they will get autodected) Options: -h --help Show this screen. """ def callback(arguments, env): args = () if arguments['list']: func = list_all elif arguments['upgrade']: args = (arguments['--rev'],) func = upgrade elif arguments['fetch']: args = (arguments['--rev'],) func = fetch elif arguments['revision']: args = (arguments['--m'], arguments['--empty']) func = revision elif arguments['downgrade']: args = (arguments['--rev'],) func = downgrade elif arguments['merge']: args = (arguments['--rev1'], arguments['--rev2']) func = merge return func(*args) try: return command(callback, migrate.__doc__) except CommandError as e: if 'has multiple heads' in e.message: print(MULTIPLE_HEADS_MSG) exit(1) else: raise
def cache_cmd(): """Test migration of costs Usage: autonomie-cache <config_uri> refresh [--type=<type>] o refresh : Ask for a cache refresh Options: -h --help Show this screen --type=<type> Only refresh cache for a given type (estimation/invoice/cancelinvoice) """ try: return command(refresh_cache, cache_cmd.__doc__) finally: pass
def migrate(): """Migrate autonomie's database Usage: migrate <config_uri> list migrate <config_uri> upgrade [--rev=<rev>] migrate <config_uri> fetch [--rev=<rev>] migrate <config_uri> revision [--m=<message>] [--empty] migrate <config_uri> downgrade [--rev=<rev>] o list : all the revisions o upgrade : upgrade the app to the latest revision o revision : create a migration file with the given message (trying to detect changes, unless --empty is used) o fetch : set the revision o downgrade : downgrade the database Options: -h --help Show this screen. """ def callback(arguments, env): args = () if arguments['list']: func = list_all elif arguments['upgrade']: args = (arguments['--rev'], ) func = upgrade elif arguments['fetch']: args = (arguments['--rev'], ) func = fetch elif arguments['revision']: args = (arguments['--m'], arguments['--empty']) func = revision elif arguments['downgrade']: args = (arguments['--rev'], ) func = downgrade return func(*args) try: return command(callback, migrate.__doc__) finally: pass
def export_cmd(): """Export utilitiy tool, stream csv datas in stdout Usage: autonomie-export <config_uri> userdatas [--fields=<fields>] [--where=<where>] autonomie-export <config_uri> invoices_pdf [--destdir=<destdir>] [--where=<where>] Options: -h --help Show this screen --fields=<fields> Export the comma separated list of fields --where=<where> Query parameters in json format descrbing statistic options --destdir=<destdir> The directory where we output the datas o userdatas : Export userdatas as csv format o invoices_pdf : Export Invoices and CancelInvoices in pdf format Streams the output in stdout autonomie-export app.ini userdatas \ --fields=coordonnees_address,coordonnees_zipcode,coordonnees_city,\ coordonnees_sex,coordonnees_birthday,statut_social_status,\ coordonnees_study_level,parcours_date_info_coll,parcours_prescripteur,\ parcours_convention_cape,activity_typologie,sortie_date,sortie_motif \ --where='[{"key":"created_at","method":"dr","type":"date",\ "search1":"1999-01-01","search2":"2016-12-31"}]'\ > /tmp/toto.csv autonomie-export """ def callback(arguments, env): if arguments['userdatas']: func = _export_userdatas_command elif arguments['invoices_pdf']: func = _invoices_pdf_command return func(arguments, env) try: return command(callback, export_cmd.__doc__) finally: pass
def export_cmd(): """Export utilitiy tool, stream csv datas in stdout Usage: autonomie-export <config_uri> userdatas [--fields=<fields>] [--where=<where>] o userdatas : export userdatas Options: -h --help Show this screen --fields=<fields> Export the comma separated list of fields --where=<where> Query parameters in json format """ def callback(arguments, env): if arguments['userdatas']: func = _export_user_datas return func(arguments, env) try: return command(callback, export_cmd.__doc__) finally: pass
def populate_fake(): """Populate the database with fake datas Usage: autonomie-fake <config_uri> populate autonomie-fake <config_uri> populate_conf Options: -h --help Show this screen. """ def callback(arguments, env): if arguments['populate']: func = fake_database_fill elif arguments['populate_conf']: func = set_configuration else: print populate_fake.__doc__ sys.exit(1) return func() try: return command(callback, populate_fake.__doc__) finally: pass
def migrate(): """Migrate autonomie's database Usage: migrate <config_uri> list migrate <config_uri> upgrade migrate <config_uri> fetch [--rev=<rev>] migrate <config_uri> revision [--m=<message>] migrate <config_uri> downgrade [--rev=<rev>] o list : all the revisions o upgrade : upgrade the app to the latest revision o revision : auto-generate a migration file with the given message o fetch : set the revision o downgrade : downgrade the database Options: -h --help Show this screen. """ def callback(arguments, env): args = () if arguments['list']: func = list_all elif arguments['upgrade']: func = upgrade elif arguments['fetch']: args = (arguments['--rev'],) func = fetch elif arguments['revision']: args = (arguments['--m'],) func = revision elif arguments['downgrade']: args = (arguments['--rev'],) func = downgrade return func(*args) try: return command(callback, migrate.__doc__) finally: pass
def autonomie_admin_cmd(): """Autonomie administration tool Usage: autonomie-admin <config_uri> useradd [--user=<user>] [--pwd=<password>] [--firstname=<firstname>] [--lastname=<lastname>] [--email=<email>] [--group=<group>] autonomie-admin <config_uri> testmail [--to=<mailadress>] o useradd : Add a user in the database o testmail : Send a test mail to [email protected] Options: -h --help Show this screen. """ def callback(arguments, env): if arguments['useradd']: func = user_add elif arguments['testmail']: func = test_mail return func(arguments, env) try: return command(callback, autonomie_admin_cmd.__doc__) finally: pass
def autonomie_admin_cmd(): """Autonomie administration tool Usage: autonomie-admin <config_uri> useradd [--user=<user>] [--pwd=<password>] [--firstname=<firstname>] [--lastname=<lastname>] [--email=<email>] [--group=<group>] autonomie-admin <config_uri> testmail [--to=<mailadress>] o useradd : Add a user in the database o testmail : Send a test mail to [email protected] Options: -h --help Show this screen. """ def callback(arguments, env): args = () if arguments['useradd']: func = user_add elif arguments['testmail']: func = test_mail return func(arguments, env) try: return command(callback, autonomie_admin_cmd.__doc__) finally: pass