~cubic-wizard/cubic/experimental

« back to all changes in this revision

Viewing changes to usr/share/cubic/cubic/navigator.py

  • Committer: PJ Singh
  • Date: 2021-11-30 01:31:16 UTC
  • Revision ID: psingh.cubic@gmail.com-20211130013116-yspl57zt59xfr1e5
* Fixed Bug #1951662, On the Copy pages, pause to allow the user to view the results before automatically transitioning away from the page. * Fixed Bug #1951693, On the Copy pages, clicking the Cancel button may be unresponsive. * Fixed Bug #1951695, Show error status on the Copy pages. * Fixed Bug #1951715, On the Generate page, clicking the Back during update checksums may be unresponsive. * Experimental fix for issue, Cannot install Cubic in Linux Mint 19.x.

Show diffs side-by-side

added added

removed removed

Lines of Context:
269
269
import threading
270
270
# import traceback
271
271
 
272
 
from cubic.utilities.displayer import SLIDE_NONE, SLIDE_LEFT, SLIDE_RIGHT, SLIDE_DOWN, SLIDE_UP
 
272
from cubic.utilities.displayer import SLIDE_NONE, SLIDE_LEFT, SLIDE_RIGHT, SLIDE_DOWN, SLIDE_UP, CROSS_FADE
273
273
from cubic.utilities import displayer
274
274
from cubic.utilities import logger
275
275
from cubic.utilities import model
321
321
 
322
322
        action_label = get_action_label(action)
323
323
        page_label = get_page_label(page)
324
 
        message = 'Action "%s" is invalid for %s.' % (action_label, page_label)
 
324
        message = f'Action "{action_label}" is invalid for {page_label}.'
325
325
        super().__init__(message)
326
326
 
327
327
 
352
352
    logger.log_title('Clicked website_menu_button')
353
353
 
354
354
    url = 'https://launchpad.net/cubic'
355
 
    command = 'xdg-open "%s" &' % url
 
355
    command = f'xdg-open "{url}" &'
356
356
    os.system(command)
357
357
 
358
358
 
361
361
    logger.log_title('Clicked help menu button')
362
362
 
363
363
    url = 'https://answers.launchpad.net/cubic'
364
 
    command = 'xdg-open "%s" &' % url
 
364
    command = f'xdg-open "{url}" &'
365
365
    os.system(command)
366
366
 
367
367
 
368
368
def on_clicked_page_help_menu_button(button):
369
369
 
370
 
    logger.log_title('Clicked help menu button')
 
370
    logger.log_title('Clicked page help menu button')
371
371
 
372
372
    url = model.help_urls[model.page.name]
373
 
    command = 'xdg-open "%s" &' % url
 
373
    command = f'xdg-open "{url}" &'
374
374
    os.system(command)
375
375
 
376
376
 
379
379
    logger.log_title('Clicked donate menu button')
380
380
 
381
381
    url = 'https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5WJL2ZE3AWGQQ&currency_code=USD&source=url'
382
 
    command = 'xdg-open "%s" &' % url
 
382
    command = f'xdg-open "{url}" &'
383
383
    os.system(command)
384
384
 
385
385
 
395
395
 
396
396
def on_close_about_dialog(widget, event):
397
397
 
398
 
    logger.log_title('Clicked close about dialog')
 
398
    logger.log_label('Clicked close about dialog')
399
399
 
400
400
    displayer.hide('about_dialog')
401
401
    displayer.set_sensitive('window', True)
431
431
 
432
432
    page_label = get_page_label(model.page)
433
433
    action_label = get_action_label(action)
434
 
    logger.log_title('Handle navigation from %s on %s action' % (page_label, action_label))
 
434
    logger.log_title(f'Handle navigation from {page_label} on {action_label} action')
435
435
 
436
436
    # Interrupt the previous navigation thread.
437
437
    interrupt_navigation_thread()
519
519
    new_page_label = get_page_label(new_page)
520
520
    action_label = get_action_label(action)
521
521
 
522
 
    logger.log_title('Navigate from %s to %s on %s action' % (page_label, new_page_label, action_label))
 
522
    logger.log_title(f'Navigate from {page_label} to {new_page_label} on {action_label} action')
523
523
 
524
524
    # Leave the current page.
525
525
 
527
527
        result = page.leave(action, new_page) if page else None
528
528
    except InterruptException as exception:
529
529
        page_label = get_page_label(page)
530
 
        logger.log_value('Error leaving %s' % page_label, exception)
 
530
        logger.log_value(f'Error leaving {page_label}', exception)
531
531
        # logger.log_value('The trace back is', traceback.format_exc())
532
532
        return
533
533
    if result:
546
546
        result = new_page.setup(action, page) if new_page else None
547
547
    except InterruptException as exception:
548
548
        page_label = get_page_label(new_page)
549
 
        logger.log_value('Error setting up %s' % page_label, exception)
 
549
        logger.log_value(f'Error setting up {page_label}', exception)
550
550
        # logger.log_value('The trace back is', traceback.format_exc())
551
551
        return
552
552
    if result:
566
566
        result = new_page.enter(action, page) if new_page else None
567
567
    except InterruptException as exception:
568
568
        page_label = get_page_label(new_page)
569
 
        logger.log_value('Error entering %s' % page_label, exception)
 
569
        logger.log_value(f'Error entering {page_label}', exception)
570
570
        # logger.log_value('The trace back is', traceback.format_exc())
571
571
        return
572
572
    page = new_page
601
601
 
602
602
    if page_name:
603
603
        try:
604
 
            page = importlib.import_module('cubic.pages.%s' % page_name)
 
604
            page = importlib.import_module(f'cubic.pages.{page_name}')
605
605
        except ModuleNotFoundError as exception:
606
606
            logger.log_value('Error', exception)
607
607
            raise exception
685
685
        specified page.
686
686
    """
687
687
 
 
688
    logger.log_title('Get the new page')
 
689
 
688
690
    page_name = get_page_name(page)
689
691
 
690
692
    page_label = get_page_label(page)
734
736
            effect = SLIDE_RIGHT
735
737
        elif action == 'test':
736
738
            new_page_name = 'test_1_page'
737
 
            effect = SLIDE_DOWN
 
739
            effect = CROSS_FADE  # SLIDE_DOWN
738
740
        elif action == 'delete':
739
741
            new_page_name = 'delete_page'
740
742
            effect = SLIDE_NONE
753
755
    elif page_name == 'test_1_page':
754
756
        if action == 'cancel':
755
757
            new_page_name = 'project_page'
756
 
            effect = SLIDE_UP
 
758
            effect = CROSS_FADE  # SLIDE_UP
757
759
        elif action == 'quit':
758
760
            new_page_name = None
759
761
            effect = SLIDE_NONE
793
795
        if action == 'back':
794
796
            new_page_name = 'project_page'
795
797
            effect = SLIDE_RIGHT
796
 
        elif action == 'copy-into-terminal':
 
798
        elif action == 'copy-terminal':
797
799
            new_page_name = 'terminal_copy_page'
798
800
            effect = SLIDE_NONE
799
801
        elif action == 'next':
809
811
        if action == 'cancel':
810
812
            new_page_name = 'terminal_page'
811
813
            effect = SLIDE_NONE
812
 
        elif action == 'copy-into-terminal':
 
814
        elif action == 'error':
 
815
            new_page_name = 'terminal_copy_page'
 
816
            effect = SLIDE_NONE
 
817
        elif action == 'copy-terminal':
813
818
            new_page_name = 'terminal_page'
814
819
            effect = SLIDE_NONE
815
820
        elif action == 'quit':
825
830
        elif action == 'next':
826
831
            new_page_name = 'packages_page'
827
832
            effect = SLIDE_LEFT
 
833
        elif action == 'next-options':
 
834
            new_page_name = 'options_page'
 
835
            effect = SLIDE_LEFT
828
836
        elif action == 'quit':
829
837
            new_page_name = None
830
838
            effect = SLIDE_NONE
838
846
        elif action == 'next':
839
847
            new_page_name = 'options_page'
840
848
            effect = SLIDE_LEFT
 
849
        elif action == 'error':
 
850
            new_page_name = 'packages_page'
 
851
            effect = SLIDE_NONE
841
852
        elif action == 'quit':
842
853
            new_page_name = None
843
854
            effect = SLIDE_NONE
848
859
        if action == 'back':
849
860
            new_page_name = 'packages_page'
850
861
            effect = SLIDE_RIGHT
 
862
        elif action == 'back-terminal':
 
863
            new_page_name = 'terminal_page'
 
864
            effect = SLIDE_RIGHT
851
865
        elif action == 'copy-preseed':
852
866
            new_page_name = 'preseed_copy_page'
853
867
            effect = SLIDE_NONE
854
 
        elif action == 'copy-boot-configuration':
 
868
        elif action == 'copy-boot':
855
869
            new_page_name = 'boot_copy_page'
856
870
            effect = SLIDE_NONE
857
871
        elif action == 'next':
867
881
        if action == 'cancel':
868
882
            new_page_name = 'options_page'
869
883
            effect = SLIDE_NONE
 
884
        elif action == 'error':
 
885
            new_page_name = 'preseed_copy_page'
 
886
            effect = SLIDE_NONE
870
887
        elif action == 'copy-preseed':
871
888
            new_page_name = 'options_page'
872
889
            effect = SLIDE_NONE
880
897
        if action == 'cancel':
881
898
            new_page_name = 'options_page'
882
899
            effect = SLIDE_NONE
883
 
        elif action == 'copy-boot-configuration':
 
900
        elif action == 'error':
 
901
            new_page_name = 'boot_copy_page'
 
902
            effect = SLIDE_NONE
 
903
        elif action == 'copy-boot':
884
904
            new_page_name = 'options_page'
885
905
            effect = SLIDE_NONE
886
906
        elif action == 'quit':
921
941
            effect = SLIDE_RIGHT
922
942
        elif action == 'test':
923
943
            new_page_name = 'test_2_page'
924
 
            effect = SLIDE_DOWN
 
944
            effect = CROSS_FADE  # SLIDE_DOWN
925
945
        elif action == 'close':
926
946
            new_page_name = None
927
947
            effect = SLIDE_NONE
934
954
    elif page_name == 'test_2_page':
935
955
        if action == 'cancel':
936
956
            new_page_name = 'finish_page'
937
 
            effect = SLIDE_UP
 
957
            effect = CROSS_FADE  # SLIDE_UP
938
958
        elif action == 'quit':
939
959
            new_page_name = None
940
960
            effect = SLIDE_NONE