Class: Yast::PackageLockClass
- Inherits:
-
Module
- Object
- Module
- Yast::PackageLockClass
- Defined in:
- library/packages/src/modules/PackageLock.rb
Instance Method Summary collapse
-
#AskPackageKit ⇒ Boolean
Ask whether to quit PackageKit if it is running.
-
#Check ⇒ Object
Tries to acquire the packager (zypp) lock.
-
#Connect(show_continue_button) ⇒ Hash
Tries to acquire the packager (zypp) lock.
- #main ⇒ Object
Instance Method Details
#AskPackageKit ⇒ Boolean
Ask whether to quit PackageKit if it is running
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'library/packages/src/modules/PackageLock.rb', line 50 def AskPackageKit ret = false if PackageKit.IsRunning # ask to send quit signal to PackageKit msg = if @packagekit_asked _( "PackageKit is still running (probably busy).\nAsk PackageKit to quit again?" ) else _( "PackageKit is blocking software management.\n" \ "This happens when the updater applet or another software management\n" \ "application is running.\n" \ "\n" \ "Ask PackageKit to quit?" ) end @packagekit_asked = true if Popup.YesNo(msg) PackageKit.SuggestQuit ret = true end end ret end |
#Check ⇒ Object
Tries to acquire the packager (zypp) lock. Reports an error if another process has the lock already. Will only report once even if called multiple times.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'library/packages/src/modules/PackageLock.rb', line 84 def Check # we already have a lock return @have_lock if !@have_lock.nil? # just to allow 'Retry', see more in bug #280383 try_again = true # while not having a lock and user wants to try again while try_again # Invoke a cheap call that accesses the zypp lock @have_lock = Pkg.Connect == true # nil guard break if @have_lock == true if @have_lock != true if AskPackageKit() # let the PackageKit quit before retrying Builtins.sleep(2000) next end try_again = Popup.AnyQuestion( # TRANSLATORS: a popup headline _("Accessing the Software Management Failed"), Ops.add( Ops.add(Pkg.LastError, "\n\n"), # TRANSLATORS: an error message with question _( "Would you like to continue without having access\nto the software management or retry to access it?\n" ) ), Label.ContinueButton, Label.RetryButton, # 'Continue' instead of 'Retry' :focus_yes ) == false end Builtins.y2milestone("User decided to retry...") if try_again end Builtins.y2milestone("PackageLock::Check result: %1", @have_lock) @have_lock end |
#Connect(show_continue_button) ⇒ Hash
Tries to acquire the packager (zypp) lock. Reports an error if another process has the lock already. Will only report once even if called multiple times.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'library/packages/src/modules/PackageLock.rb', line 133 def Connect() # we already have a lock return { "connected" => @have_lock, "aborted" => @aborted } if !@have_lock.nil? try_again = true # while not having a lock and user wants to try again while try_again # Invoke a cheap call that accesses the zypp lock @have_lock = Pkg.Connect == true # nil guard break if @have_lock == true if @have_lock != true if AskPackageKit() # let the PackageKit quit before retrying Builtins.sleep(2000) next end if ret2 = Popup.AnyQuestion3( # TRANSLATORS: a popup headline _("Accessing the Software Management Failed"), Ops.add( Ops.add(Pkg.LastError, "\n\n"), # TRANSLATORS: an error message with question _( "Would you like to retry accessing the software manager,\n" \ "continue without having access to the software management,\n" \ "or abort?\n" ) ), Label.RetryButton, Label.ContinueButton, Label.AbortButton, # default is 'Retry' :focus_yes ) try_again = ret2 == :yes # NOTE: due to the changed labels this actually means that [Abort] was pressed!! @aborted = true if ret2 == :retry else ret2 = Popup.AnyQuestion( # TRANSLATORS: a popup headline _("Accessing the Software Management Failed"), Ops.add( Ops.add(Pkg.LastError, "\n\n"), # TRANSLATORS: an error message with question _("Would you like to abort or try again?\n") ), Label.RetryButton, Label.AbortButton, # default is 'Retry' :focus_yes ) try_again = ret2 @aborted = !ret2 end Builtins.y2milestone( "try_again: %1, aborted: %2", try_again, @aborted ) end Builtins.y2milestone("User decided to retry...") if try_again end ret = { "connected" => @have_lock, "aborted" => @aborted } Builtins.y2milestone("PackageLock::Connect result: %1", ret) deep_copy(ret) end |
#main ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'library/packages/src/modules/PackageLock.rb', line 34 def main Yast.import "Pkg" textdomain "base" Yast.import "Popup" Yast.import "Label" Yast.import "PackageKit" @have_lock = nil @aborted = false # display a different message in the first PackageKit quit confirmation @packagekit_asked = false end |