Implement support for incremental client updates
This commit is contained in:
parent
cbf19aede9
commit
7858e7a460
1 changed files with 19 additions and 3 deletions
|
@ -3,6 +3,7 @@ from core.Errors import MissingSubscriptionError, InvalidSubscriptionError, Unkn
|
||||||
from core.controllers.ApplicationController import ApplicationController
|
from core.controllers.ApplicationController import ApplicationController
|
||||||
from core.controllers.ApplicationVersionController import ApplicationVersionController
|
from core.controllers.ApplicationVersionController import ApplicationVersionController
|
||||||
from core.controllers.ClientController import ClientController
|
from core.controllers.ClientController import ClientController
|
||||||
|
from core.controllers.ClientVersionController import ClientVersionController
|
||||||
from core.controllers.ConfigurationController import ConfigurationController
|
from core.controllers.ConfigurationController import ConfigurationController
|
||||||
from core.controllers.InvoiceController import InvoiceController
|
from core.controllers.InvoiceController import InvoiceController
|
||||||
from core.controllers.LocationController import LocationController
|
from core.controllers.LocationController import LocationController
|
||||||
|
@ -42,6 +43,10 @@ if __name__ == '__main__':
|
||||||
application_version_observer.subscribe('downloaded', lambda event: print('\n'))
|
application_version_observer.subscribe('downloaded', lambda event: print('\n'))
|
||||||
|
|
||||||
client_observer.subscribe('synchronizing', lambda event: print('Synchronizing...\n'))
|
client_observer.subscribe('synchronizing', lambda event: print('Synchronizing...\n'))
|
||||||
|
client_observer.subscribe('updating', lambda event: print('Updating client...'))
|
||||||
|
client_observer.subscribe('update_progressing', lambda event: print(f'Current progress: {event.meta.get('progress'):.2f}%', flush=True, end='\r'))
|
||||||
|
client_observer.subscribe('updated', lambda event: print('\n'))
|
||||||
|
|
||||||
connection_observer.subscribe('connecting', lambda event: print(f'[{event.subject.get("attempt_count")}/{event.subject.get("maximum_number_of_attempts")}] Performing connection attempt...\n'))
|
connection_observer.subscribe('connecting', lambda event: print(f'[{event.subject.get("attempt_count")}/{event.subject.get("maximum_number_of_attempts")}] Performing connection attempt...\n'))
|
||||||
|
|
||||||
invoice_observer.subscribe('retrieved', lambda event: print(f'\n{pprint.pp(event.subject)}\n'))
|
invoice_observer.subscribe('retrieved', lambda event: print(f'\n{pprint.pp(event.subject)}\n'))
|
||||||
|
@ -159,6 +164,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
sync_parser = main_subparsers.add_parser('sync')
|
sync_parser = main_subparsers.add_parser('sync')
|
||||||
|
|
||||||
|
update_parser = main_subparsers.add_parser('update')
|
||||||
|
|
||||||
arguments = main_parser.parse_args()
|
arguments = main_parser.parse_args()
|
||||||
|
|
||||||
if arguments.command is None:
|
if arguments.command is None:
|
||||||
|
@ -358,9 +365,6 @@ if __name__ == '__main__':
|
||||||
else:
|
else:
|
||||||
main_parser.error('the following argument should be a valid reference: --application/-a')
|
main_parser.error('the following argument should be a valid reference: --application/-a')
|
||||||
|
|
||||||
elif arguments.command == 'sync':
|
|
||||||
ClientController.sync(client_observer=client_observer, connection_observer=connection_observer)
|
|
||||||
|
|
||||||
elif arguments.command == 'get':
|
elif arguments.command == 'get':
|
||||||
|
|
||||||
if arguments.subcommand is None:
|
if arguments.subcommand is None:
|
||||||
|
@ -376,3 +380,15 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
elif arguments.subcommand == 'connection':
|
elif arguments.subcommand == 'connection':
|
||||||
ConfigurationController.set_connection(arguments.connection_type)
|
ConfigurationController.set_connection(arguments.connection_type)
|
||||||
|
|
||||||
|
elif arguments.command == 'sync':
|
||||||
|
ClientController.sync(client_observer=client_observer, connection_observer=connection_observer)
|
||||||
|
|
||||||
|
elif arguments.command == 'update':
|
||||||
|
|
||||||
|
client_version = ClientController.get_version()
|
||||||
|
|
||||||
|
if ClientVersionController.is_latest(client_version):
|
||||||
|
print('The client is already up to date.\n')
|
||||||
|
|
||||||
|
ClientController.update(client_observer=client_observer, connection_observer=connection_observer)
|
||||||
|
|
Loading…
Reference in a new issue