~ubuntu-branches/ubuntu/saucy/hplip/saucy-proposed

« back to all changes in this revision

Viewing changes to installer/text_install.py

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2012-05-26 11:20:39 UTC
  • mfrom: (1.5.6) (31.1.3 precise)
  • Revision ID: package-import@ubuntu.com-20120526112039-bevxczegxnbyr5m7
Tags: 3.12.4-1
* New upstream release
* Switch to source/format 3.0 (quilt) - drop dpatch
* Refreshed debian/patches
* dh_autoreconf debian/autogen.sh & set local-options single-debian-patch
* Update to debian/compat -> 9
* Fix "hardened build flags" patch from Moritz - thanks (Closes: #667828)
* Fix "duplex descriptor uninitialized" patch from Matej (Closes: #583273)
* Fix "please migrate to kde-runtime" patch from Pino (Closes: #666544)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
# -*- coding: utf-8 -*-
3
3
#
4
 
# (c) Copyright 2003-2009 Hewlett-Packard Development Company, L.P.
 
4
# (c) Copyright 2003-2014 Hewlett-Packard Development Company, L.P.
5
5
#
6
6
# This program is free software; you can redistribute it and/or modify
7
7
# it under the terms of the GNU General Public License as published by
17
17
# along with this program; if not, write to the Free Software
18
18
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19
19
#
20
 
# Author: Don Welch
 
20
# Author: Don Welch, Amarnath Chitumalla
21
21
#
22
22
 
23
23
# Std Lib
32
32
from core_install import *
33
33
 
34
34
def start_systray():
 
35
    tui.title("RE-STARTING HP_SYSTRAY")
35
36
    path = utils.which('hp-systray')
36
37
    if path:
37
38
        path = os.path.join(path, 'hp-systray')
90
91
 
91
92
        log.info("")
92
93
        log.note("Defaults for each question are maked with a '*'. Press <enter> to accept the default.")
 
94
        core.init()
 
95
        if not core.distro_name in ("ubuntu","debian","suse","fedora"):
 
96
            log.error("Auto installation is not supported for '%s' distro so all dependencies may not be installed. \nPlease install manually as mentioned in 'http://hplipopensource.com/hplip-web/install/manual/index.html' web-site"% core.distro_name)
 
97
            ok, choice = tui.enter_choice("\nPress 'y' If you still want to continue auto installation. Press 'n' to quit auto instalation(y=yes, n=no*): ",['y','n'],'n')
 
98
            if not ok or choice =='n':
 
99
                log.info("Installation exit")
 
100
                sys.exit()
93
101
 
94
102
        if not auto:
95
103
            tui.title("INSTALLATION MODE")
116
124
                return
117
125
 
118
126
        log.info("\nInitializing. Please wait...")
119
 
        core.init()
 
127
        prev_hplip_version= sys_conf.get("hplip","version","0.0.0")
 
128
 
120
129
 
121
130
        if test_unknown:
122
131
            core.distro_name = 'unknown'
125
134
 
126
135
 
127
136
        #
128
 
        # HPLIP vs. HPIJS INSTALLATION
 
137
        # HPLIP INSTALLATION
129
138
        #
130
 
 
131
 
        #if not auto:
132
 
            #tui.title("INSTALL TYPE")
133
 
            #log.info("For most users, it is recommended to install HPLIP with full support (scanning, faxing, toolbox, etc).")
134
 
            #log.info("For servers or minimal installations, you can also install print support only (HPIJS only).")
135
 
 
136
 
            #ok, choice = tui.enter_choice("\nInstall full hplip support (recommended) or print-only support (f=full hplip support*, p=printing only support, q=quit) ?",
137
 
                #['f', 'p'], 'f')
138
 
            #if not ok: sys.exit(0)
139
 
            #if choice  == 'p':
140
 
                #core.selected_component = 'hpijs'
141
 
 
142
 
        #log.debug(core.selected_component)
143
139
        core.selected_component = 'hplip'
144
140
 
145
141
        #
150
146
 
151
147
        if core.selected_component == 'hplip':
152
148
            log.info("This installer will install HPLIP version %s on your computer." % core.version_public)
153
 
            #core.hpijs_build = False
154
 
        #else:
155
 
            #log.info("This installer will install HPIJS version %s on your computer." % core.version_public)
156
 
            #core.hpijs_build = True
157
149
 
158
150
        log.info("Please close any running package management systems now (YaST, Adept, Synaptic, Up2date, etc).")
159
151
 
160
 
##        #
161
 
##        # RELEASE NOTES
162
 
##        #
163
 
##
164
 
##        if not auto:
165
 
##            if os.getenv('DISPLAY'):
166
 
##                tui.title("VIEW RELEASE NOTES")
167
 
##                log.info("Release notes from this version are available as a web (HTML) document.")
168
 
##                log.info("The release notes file will be shown in a separate web browser window.")
169
 
##
170
 
##                ok, ans = tui.enter_yes_no("\nWould you like to view the release notes for this version of HPLIP", 'n')
171
 
##
172
 
##                if ok and ans:
173
 
##                    log.info("Displaying release notes in a browser window...")
174
 
##                    core.show_release_notes_in_browser()
175
 
##
176
 
##                if not ok:
177
 
##                    sys.exit(0)
178
152
 
179
153
        # For testing, mark all dependencies missing
180
154
        if test_depends:
327
301
 
328
302
                sys.exit(1)
329
303
 
 
304
 
330
305
        #
331
306
        # SELECT OPTIONS TO INSTALL
332
307
        #
333
308
 
334
 
 
335
 
 
336
309
        if not auto:
337
310
            tui.title("SELECT HPLIP OPTIONS")
338
311
            log.info("You can select which HPLIP options to enable. Some options require extra dependencies.")
339
312
            log.info("")
340
313
            num_opt_missing = core.select_options(option_question_callback)
341
314
 
342
 
        #else: # auto
343
 
            #ok, enable_par = tui.enter_yes_no("Would you like to enable support for parallel (LPT:) connected printers?", 'n')
344
 
            #if not ok: sys.exit(0)
345
 
 
346
 
            #core.selected_options['parallel'] = enable_par
347
 
 
348
 
            #if enable_par:
349
 
                #log.info("Parallel support enabled.")
350
315
        else:
351
316
            enable_par = False
352
317
            core.selected_options['parallel'] = False
371
336
                log.error("3 incorrect attempts. (or) Insufficient permissions(i.e. try with sudo user).\nExiting.")
372
337
                sys.exit(1)
373
338
 
374
 
        #
 
339
 
375
340
        # INSTALLATION NOTES
376
341
        #
377
342
 
440
405
                    log.error("Installation cannot continue without this dependency. Please manually install this dependency and re-run this installer.")
441
406
                    sys.exit(0)
442
407
 
443
 
                #log.info("-"*10)
444
 
                #log.info("")
445
 
 
446
408
        #
447
409
        # OPTIONAL dependencies
448
410
        #
493
455
                        core.selected_options[opt] = False
494
456
 
495
457
 
496
 
                #log.info("-"*10)
497
 
                #log.info("")
498
 
 
499
 
 
500
 
        log.debug("Dependencies to install: %s" % depends_to_install)
 
458
 
 
459
        log.debug("Dependencies to install: %s  hplip_present:%s" % (depends_to_install, core.hplip_present))
501
460
 
502
461
        if core.distro_version_supported and \
503
462
            (depends_to_install or core.hplip_present) and \
536
495
            #
537
496
            # CHECK FOR ACTIVE NETWORK CONNECTION
538
497
            #
539
 
 
540
498
            if not assume_network:
541
499
                tui.title("CHECKING FOR NETWORK CONNECTION")
542
500
 
543
501
                if not core.check_network_connection():
544
 
                    log.error("\nThe network appears to be unreachable. Installation cannot complete without access to")
545
 
                    log.error("distribution repositories. Please check the network and try again.")
546
 
                    sys.exit(1)
 
502
                    log.error("The network appears to be unreachable. Installation may not resolve all dependencies without access to distribution repositories.")
 
503
                    ok, choice = tui.enter_choice("Do you want to continue installation without network?. Press 'y' for YES. Press 'n' for NO (y=yes*, n=no) : ",['y', 'n'], 'y')
 
504
                    if not ok or choice == 'n':
 
505
                        log.info("Please connect network and try again")
 
506
                        sys.exit(1)
 
507
                    else:
 
508
                        log.debug("Continuing installation without network")
547
509
                else:
548
510
                    log.info("Network connection present.")
549
511
 
662
624
                        sys.exit(1)
663
625
 
664
626
 
665
 
            ##
666
 
            ## HPOJ REMOVAL
667
 
            ##
668
 
 
669
 
            #if core.hpoj_present and core.selected_component == 'hplip' and core.distro_version_supported:
670
 
                #log.error("HPOJ is installed and/or running. HPLIP is not compatible with HPOJ.")
671
 
                #failed = True
672
 
                #hpoj_remove_cmd = core.get_distro_data('hpoj_remove_cmd')
673
 
 
674
 
                #if hpoj_remove_cmd:
675
 
                    #if auto:
676
 
                        #answer = True
677
 
                    #else:
678
 
                        #ok, answer = tui.enter_yes_no("\nWould you like to have this installer attempt to uninstall HPOJ")
679
 
 
680
 
                    #if not ok: sys.exit(0)
681
 
 
682
 
                    #if answer:
683
 
                        #failed = core.remove_hpoj(progress_callback)
684
 
 
685
 
                        #if failed:
686
 
                            #log.error("HPOJ removal failed. Please manually stop/remove/uninstall HPOJ and then re-run this installer.")
687
 
                            #sys.exit(1)
688
 
                    #else:
689
 
                        #log.error("Please stop/remove/uninstall HPOJ and then re-run this installer.")
690
 
                        #sys.exit(1)
691
 
 
692
 
                #else:
693
 
                    #log.error("Please stop/remove/uninstall HPOJ and then re-run this installer.")
694
 
                    #sys.exit(1)
695
627
 
696
628
 
697
629
            #
698
630
            # HPLIP REMOVE
699
631
            #
700
 
 
701
632
            if core.hplip_present and core.selected_component == 'hplip' and core.distro_version_supported:
702
 
                failed = True
703
 
                log.warn("A previous install of HPLIP is installed and/or running.")
 
633
                path = utils.which('hp-uninstall')
 
634
                ok, choice = tui.enter_choice("HPLIP-%s exists, this may conflict with the new one being installed.\nDo you want to ('i'= Remove and Install, 'o'= Overwrite*, 'q'= Quit)?      :"%(prev_hplip_version),['i','o','q'],'o')
 
635
                if not ok or choice=='q':
 
636
                    log.error("User Exit")
 
637
                    sys.exit(0)
 
638
                elif choice == 'i':
 
639
#                    log.info("Uninstalling existing HPLIP-%s"%prev_hplip_version)
 
640
                    sts =core.uninstall(NON_INTERACTIVE_MODE)
704
641
 
705
 
                hplip_remove_cmd = core.get_distro_data('hplip_remove_cmd')
706
 
                if hplip_remove_cmd:
707
 
                    if auto:
708
 
                        answer = True
 
642
                    if sts is False: 
 
643
                        log.warn("Failed to uninstall existing HPLIP-%s. This installation will overwrite on existing HPLIP" %prev_hplip_version)
709
644
                    else:
710
 
                        ok, answer = tui.enter_yes_no("\nWould you like to have this installer attempt to uninstall the previously installed HPLIP")
711
 
                    if not ok: sys.exit(0)
712
 
 
713
 
                    if answer:
714
 
                        failed = core.remove_hplip(progress_callback)
715
 
 
716
 
                else:
717
 
                    log.error("The previously installed version of HPLIP may conflict with the new one being installed.")
718
 
                    log.error("It is recommended that you quit this installer, and manually remove HPLIP before continuing.")
719
 
                    sys.exit(0)
720
 
 
721
 
                if failed:
722
 
                    log.warn("HPLIP removal failed. The previous install may have been installed using a tarball or this installer.")
723
 
                    log.warn("Continuing to run installer - this installation should overwrite the previous one.")
724
 
 
 
645
                        log.debug("HPLIP-%s is uninstalled successfully." %prev_hplip_version)
725
646
 
726
647
            #
727
648
            # POST-DEPEND
728
649
            #
729
 
 
730
650
            tui.title("RUNNING POST-PACKAGE COMMANDS")
731
651
            core.run_post_depend(progress_callback)
732
652
            log.info("OK")
735
655
            #
736
656
            # DEPENDENCIES RE-CHECK
737
657
            #
738
 
 
739
658
            tui.title("RE-CHECKING DEPENDENCIES")
740
659
            core.check_dependencies()
741
660
 
818
737
        #
819
738
        # OPEN MDNS MULTICAST PORT
820
739
        #
821
 
 
 
740
        user_conf = UserConfig()
 
741
        
822
742
        if core.selected_options['network']:
823
743
            open_mdns_port = core.get_distro_ver_data('open_mdns_port')
824
744
            if open_mdns_port:
845
765
 
846
766
        if current_version >= 0x030902: # 3.9.2
847
767
            try:
848
 
                # dBus
849
 
                #import dbus
850
768
                from dbus import SessionBus, lowlevel
851
769
            except ImportError:
852
 
                #log.error("Unable to load DBus")
853
770
                pass
854
771
            else:
855
772
                try:
863
780
                except:
864
781
                    pass
865
782
        
866
 
        tui.title("RE-STARTING HP_SYSTRAY")
867
 
        start_systray()
868
 
 
869
 
        # Restart or re-plugin if necessary (always True in 2.7.9+)
 
783
        tui.title("HPLIP UPDATE NOTIFICATION")
 
784
        ok, choice = tui.enter_choice("Do you want to check for HPLIP updates?. (y=yes*, n=no) : ",['y', 'n'], 'y')
 
785
        if not ok or choice != 'y':
 
786
            user_conf.set('upgrade', 'notify_upgrade', 'false')
 
787
        else:
 
788
            user_conf.set('upgrade', 'notify_upgrade', 'true')
 
789
 
 
790
        user_conf.set('upgrade','last_upgraded_time',str(int(time.time())))
 
791
        user_conf.set('upgrade','pending_upgrade_time','0')
 
792
 
 
793
 
870
794
        if core.selected_component == 'hplip':
871
795
            tui.title("RESTART OR RE-PLUG IS REQUIRED")
872
796
            cmd = "hp-setup"
879
803
            ok, choice = tui.enter_choice("Restart or re-plug in your printer (r=restart, p=re-plug in*, i=ignore/continue, q=quit) : ",
880
804
                ['r', 'p', 'i'], 'p')
881
805
 
882
 
            if not ok: sys.exit(0)
 
806
            if not ok: 
 
807
                start_systray()
 
808
                sys.exit(0)
883
809
 
884
810
            if choice == 'r':
885
811
                log.note("")
886
812
                log.note("IMPORTANT! Make sure to save all work in all open applications before restarting!")
887
813
 
888
814
                ok, ans = tui.enter_yes_no(log.bold("Restart now"), 'n')
889
 
                if not ok: sys.exit(0)
 
815
                if not ok: 
 
816
                    start_systray()
 
817
                    sys.exit(0)
890
818
                if ans:
891
819
                    ok = core.restart()
892
820
                    if not ok:
893
821
                        log.error("Restart failed. Please restart using the system menu.")
894
822
 
 
823
                start_systray()
895
824
                sys.exit(0)
896
825
 
897
826
            elif choice == 'p': # 'p'
898
827
                if not tui.continue_prompt("Please unplug and re-plugin your printer now. "):
 
828
                    start_systray()
899
829
                    sys.exit(0)
900
830
 
901
831
 
909
839
                install_printer = True
910
840
            else:
911
841
                ok, install_printer = tui.enter_yes_no("Would you like to setup a printer now")
912
 
                if not ok: sys.exit(0)
 
842
                if not ok:
 
843
                    start_systray()
 
844
                    sys.exit(0)
913
845
 
914
846
            if install_printer:
915
847
                log.info("Please make sure your printer is connected and powered on at this time.")
916
848
                if not core.run_hp_setup():
917
849
                    log.error("hp-setup failed. Please run hp-setup manually.")
918
850
 
 
851
        start_systray()
919
852
    except KeyboardInterrupt:
920
853
        log.info("")
921
854
        log.error("Aborted.")