Class: Yast::PackageSlideShowClass
- Inherits:
-
Module
- Object
- Module
- Yast::PackageSlideShowClass
- Defined in:
- ../../src/modules/PackageSlideShow.rb
Instance Method Summary (collapse)
-
- (Object) CdProgressId(src_no, cd_no)
Return a CD's progress bar ID.
-
- (Object) CdStatisticsTableItems
Returns a table widget item list for CD statistics.
- - (Object) DisplayGlobalProgress
- - (Object) DoneProvide(error, reason, name)
-
- (Object) FindNextMedia
Try to figure out what media will be needed next and set next_src_no and next_cd_no accordingly.
- - (Object) FormatNextMedia
-
- (String) FormatRemainingCount(remaining)
Format number of remaining packages to be installed as string.
-
- (String) FormatRemainingSize(remaining)
Format number of remaining bytes to be installed as string.
-
- (Object) FormatTimeShowOverflow(seconds)
Format an integer seconds value with min:sec or hours:min:sec.
- - (Object) GetPackageSummary
-
- (Object) InitPkgData(force)
Initialize internal pacakge data, such as remaining package sizes and times.
-
- (Object) ListSum(sizes)
Sum up all list items.
-
- (Object) ListSumCutOff(sizes, max_cutoff)
Sum up all positive list items, but cut off individual items at a maximum value.
- - (Object) main
- - (Object) packages_to_download(src_mapping)
- - (Object) packages_to_install(src_mapping)
-
- (Object) RecalcRemainingTimes(force_recalc)
Recalculate remaining times per CD based on package sizes remaining and data rate so far.
- - (Object) ResetPackageSummary
-
- (Object) SanityCheck(silent)
Perform sanity check for correct initialzation etc.
-
- (Object) SetCurrentCdNo(src_no, cd_no)
Set the current repository and CD number.
-
- (Object) SetMediaType(new_media_type)
set media type “CD” or “DVD”.
- - (Object) SlideDeltaApplyStart(pkg_name)
-
- (Object) SlideDisplayDone(pkg_name, pkg_size, deleting)
package start display update - this is called at the end of a new package.
-
- (Object) SlideDisplayStart(pkg_name, pkg_location, pkg_summary, pkg_size, deleting)
package start display update - this is called at the beginning of a new package.
- - (Object) SlideGenericProvideStart(pkg_name, sz, pattern, remote)
-
- (Object) SlideProvideStart(pkg_name, sz, remote)
Package providal start.
-
- (String) StripPath(pkg_name)
Get package file name from path.
-
- (Object) StripReleaseNo(pkg_name)
Get version info for a package (without build no.).
-
- (Object) SubtractPackageSize(pkg_size)
Update internal bookkeeping: subtract size of one package from the global list of remaining sizes per CD.
-
- (Object) SwitchToSecondsIfNecessary
Switch unit to seconds if necessary and recalc everything accordingly.
- - (Object) TotalInstalledSize
- - (Object) TotalRemainingPkgCount
- - (Object) TotalRemainingSize
- - (Object) TotalRemainingTime
-
- (Object) UpdateAllCdProgress(silent_check)
Update progress widgets for all CDs.
-
- (Object) UpdateCurrentCdProgress(silent_check)
Update progress widgets for the current CD: Label and ProgressBar.
-
- (Object) UpdateCurrentPackageProgress(pkg_percent)
Progress display update This is called via the packager's progress callbacks.
-
- (Object) UpdateCurrentPackageRateProgress(pkg_percent, bps_avg, bps_current)
update the download rate.
-
- (Object) UpdateTotalProgress(silent_check)
Update progress widgets.
-
- (Object) UpdateTotalProgressValue
update the overall progress value (download + installation).
Instance Method Details
- (Object) CdProgressId(src_no, cd_no)
Return a CD's progress bar ID
1264 1265 1266 |
# File '../../src/modules/PackageSlideShow.rb', line 1264 def CdProgressId(src_no, cd_no) Builtins.sformat("Src %1 CD %2", src_no, cd_no) end |
- (Object) CdStatisticsTableItems
Returns a table widget item list for CD statistics
1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 |
# File '../../src/modules/PackageSlideShow.rb', line 1034 def CdStatisticsTableItems itemList = [] # # Add "Total" item - at the top so it is visible by default even if there are many items # # List column header for total remaining MB and time to install caption = _("Total") remaining = TotalRemainingSize() rem_size = FormatRemainingSize(remaining) rem_count = FormatRemainingCount(TotalRemainingPkgCount()) rem_time = "" if @unit_is_seconds && Ops.greater_than(@bytes_per_second, 0) rem_time = FormatTimeShowOverflow(TotalRemainingTime()) end itemList = Builtins.add( itemList, SlideShow.TableItem( "total", caption, Ops.add(" ", rem_size), Ops.add(" ", rem_count), Ops.add(" ", rem_time) ) ) # # Now go through all repositories # src_no = 0 Builtins.foreach(@remaining_sizes_per_cd_per_src) do |inst_src| Builtins.y2milestone("src #%1: %2", src_no, inst_src) if Ops.greater_than(ListSum(inst_src), 0) # Ignore repositories from where there is nothing is to install # Add heading for this repository itemList = Builtins.add( itemList, SlideShow.TableItem( Builtins.sformat("src(%1)", src_no), Ops.get(@inst_src_names, src_no, ""), "", "", "" ) ) cd_no = 0 Builtins.foreach(inst_src) do |remaining| if Ops.greater_than(remaining, 0) || Ops.add(src_no, 1) == @current_src_no && Ops.add(cd_no, 1) == @current_cd_no # suppress current CD caption = Builtins.sformat(@media_type, Ops.add(cd_no, 1)) # "Medium 1" - column #0 rem_size = FormatRemainingSize(remaining) # column #1 rem_count = FormatRemainingCount( Ops.get(@remaining_pkg_count_per_cd_per_src, [src_no, cd_no], 0) ) rem_time = "" if @unit_is_seconds && Ops.greater_than(@bytes_per_second, 0) remaining = Ops.divide(remaining, @bytes_per_second) rem_time = String.FormatTime(remaining) # column #2 if Ops.greater_than(remaining, @max_time_per_cd) # clip off at 2 hours # When data throughput goes downhill (stalled network connection etc.), # cut off the predicted time at a reasonable maximum. # "%1" is a predefined maximum time. rem_time = FormatTimeShowOverflow( Ops.unary_minus(@max_time_per_cd) ) end end itemList = Builtins.add( itemList, SlideShow.TableItem( Builtins.sformat("cd(%1,%2)", src_no, cd_no), # ID caption, Ops.add(" ", rem_size), Ops.add(" ", rem_count), Ops.add(" ", rem_time) ) ) end cd_no = Ops.add(cd_no, 1) end end src_no = Ops.add(src_no, 1) end if @debug Builtins.y2milestone("Remaining: %1", @remaining_sizes_per_cd_per_src) Builtins.y2milestone("CD table item list:\n%1", itemList) end deep_copy(itemList) end |
- (Object) DisplayGlobalProgress
1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 |
# File '../../src/modules/PackageSlideShow.rb', line 1179 def DisplayGlobalProgress rem_string = "" tot_rem_t = TotalRemainingTime() rem_string = @unit_is_seconds && Ops.greater_than(@bytes_per_second, 0) && Ops.greater_than(tot_rem_t, 0) ? Builtins.sformat( "%1 / %2", FormatRemainingSize(TotalRemainingSize()), FormatTimeShowOverflow(tot_rem_t) ) : FormatRemainingSize(TotalRemainingSize()) rem_string = Ops.add(rem_string, ", ") if rem_string != "" SlideShow.SetGlobalProgressLabel( Ops.add( SlideShow.CurrentStageDescription, Builtins.sformat( _(" (Remaining: %1%2 packages)"), rem_string, TotalRemainingPkgCount() ) ) ) nil end |
- (Object) DoneProvide(error, reason, name)
1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 |
# File '../../src/modules/PackageSlideShow.rb', line 1208 def DoneProvide(error, reason, name) if error == 0 @total_downloaded = Ops.add(@total_downloaded, @current_provide_size) @total_count_downloaded = Ops.add(@total_count_downloaded, 1) Builtins.y2milestone( "Downloaded %1/%2 packages", @total_count_downloaded, @total_count_to_download ) # move the progress also for downloaded files UpdateTotalProgressValue() d_mode = Ops.get_symbol(Pkg.CommitPolicy, "download_mode", :default) if d_mode == :download_in_advance || d_mode == :default && Mode.normal && !Installation.dirinstall_installing_into_dir # display download progress in DownloadInAdvance mode # translations: progress message (part1) SlideShow.SetGlobalProgressLabel( Ops.add( _("Downloading Packages..."), # progress message (part2) Builtins.sformat( _(" (Downloaded %1 of %2 packages)"), @total_count_downloaded, @total_count_to_download ) ) ) end end nil end |
- (Object) FindNextMedia
Try to figure out what media will be needed next and set next_src_no and next_cd_no accordingly.
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
# File '../../src/modules/PackageSlideShow.rb', line 569 def FindNextMedia # Normally we would have to use current_cd_no+1, # but since this uses 1..n and we need 0..n-1 # for array subscripts anyway, use it as it is. @next_cd_no = @current_cd_no @next_src_no = Ops.subtract(@current_src_no, 1) @last_cd = false while Ops.less_than( @next_src_no, Builtins.size(@remaining_sizes_per_cd_per_src) ) remaining_sizes = Ops.get( @remaining_sizes_per_cd_per_src, @next_src_no, [] ) while Ops.less_than(@next_cd_no, Builtins.size(remaining_sizes)) if Ops.greater_than(Ops.get(remaining_sizes, @next_cd_no, 0), 0) if @debug Builtins.y2milestone( "Next media: src: %1 CD: %2", @next_src_no, @next_cd_no ) end return else @next_cd_no = Ops.add(@next_cd_no, 1) end end @next_src_no = Ops.add(@next_src_no, 1) end Builtins.y2milestone("No next media - all done") if @debug @next_src_no = -1 @next_cd_no = -1 @last_cd = true nil end |
- (Object) FormatNextMedia
278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File '../../src/modules/PackageSlideShow.rb', line 278 def FormatNextMedia text = "" if Ops.greater_or_equal(@next_src_no, 0) && Ops.greater_or_equal(@next_cd_no, 0) next_media_name = Builtins.sformat( "%1 %2", Ops.get(@inst_src_names, @next_src_no, ""), Builtins.sformat(@media_type, Ops.add(@next_cd_no, 1)) ) if @unit_is_seconds # Status line informing about the next CD that will be used # %1: Media type ("CD" / "DVD", ???) # %2: Media name ("SuSE Linux Professional CD 2" ) # %3: Time remaining until this media will be needed text = Builtins.sformat( _("Next: %1 -- %2"), next_media_name, String.FormatTime( Ops.get( @remaining_times_per_cd_per_src, [ Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1) ], 1 ) ) ) else # Status line informing about the next CD that will be used # %1: Media type ("CD" / "DVD", ???) # %2: Media name ("SuSE Linux Professional CD 2" ) text = Builtins.sformat(_("Next: %1"), next_media_name) end end text end |
- (String) FormatRemainingCount(remaining)
Format number of remaining packages to be installed as string.
267 268 269 270 271 272 273 274 275 |
# File '../../src/modules/PackageSlideShow.rb', line 267 def FormatRemainingCount(remaining) if Ops.less_than(remaining, 0) # Nothing more to install from this CD (very concise - little space!!) return _("Done.") end return "" if remaining == 0 Builtins.sformat("%1", remaining) end |
- (String) FormatRemainingSize(remaining)
Format number of remaining bytes to be installed as string.
252 253 254 255 256 257 258 259 260 |
# File '../../src/modules/PackageSlideShow.rb', line 252 def FormatRemainingSize(remaining) if Ops.less_than(remaining, 0) # Nothing more to install from this CD (very concise - little space!!) return _("Done.") end return "" if remaining == 0 String.FormatSize(remaining) end |
- (Object) FormatTimeShowOverflow(seconds)
Format an integer seconds value with min:sec or hours:min:sec
Negative values are interpreted as overflow - “>” is prepended and the absolute value is used.
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File '../../src/modules/PackageSlideShow.rb', line 228 def FormatTimeShowOverflow(seconds) text = "" if Ops.less_than(seconds, 0) # Overflow (indicated by negative value) # When data throughput goes downhill (stalled network connection etc.), # cut off the predicted time at a reasonable maximum. # "%1" is a predefined maximum time. text = Builtins.sformat( _(">%1"), String.FormatTime(Ops.unary_minus(seconds)) ) else text = String.FormatTime(seconds) end text end |
- (Object) GetPackageSummary
100 101 102 103 104 105 106 107 108 109 110 111 |
# File '../../src/modules/PackageSlideShow.rb', line 100 def GetPackageSummary { "installed" => @installed_packages, "updated" => @updated_packages, "removed" => @removed_packages, "installed_list" => @installed_packages_list, "updated_list" => @updated_packages_list, "removed_list" => @removed_packages_list, "downloaded_bytes" => @total_downloaded, "installed_bytes" => @total_installed } end |
- (Object) InitPkgData(force)
Initialize internal pacakge data, such as remaining package sizes and times. This may not be called before the pkginfo server is up and running, so this cannot be reliably done from the constructor in all cases.
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
# File '../../src/modules/PackageSlideShow.rb', line 483 def InitPkgData(force) return if @init_pkg_data_complete && !force ResetPackageSummary() # Reinititalize some globals (in case this is a second run) @total_size_installed = 0 #total_time_elapsed = 0; #start_time = -1; @current_src_no = -1 # 1..n @current_cd_no = -1 # 1..n @next_src_no = -1 @next_cd_no = -1 @last_cd = false @unit_is_seconds = false # begin with package sizes @bytes_per_second = 1 src_list = Pkg.PkgMediaNames @inst_src_names = Builtins.maplist(src_list) do |src| Ops.get_string(src, 0, "CD") end Builtins.y2milestone("Media names: %1", @inst_src_names) index = 0 @srcid_to_current_src_no = Builtins.listmap(src_list) do |src| index = Ops.add(index, 1) { Ops.get_integer(src, 1, -1) => index } end Builtins.y2milestone( "Repository mapping information: %1", @srcid_to_current_src_no ) @total_sizes_per_cd_per_src = Pkg.PkgMediaSizes @total_pkg_count_per_cd_per_src = Pkg.PkgMediaCount @total_size_to_install = ListSum( Builtins.flatten(@total_sizes_per_cd_per_src) ) Builtins.y2milestone("total_size_to_install: %1", @total_size_to_install) @remaining_sizes_per_cd_per_src = Builtins.eval( @total_sizes_per_cd_per_src ) @remaining_pkg_count_per_cd_per_src = Builtins.eval( @total_pkg_count_per_cd_per_src ) @total_cd_count = Builtins.size( Builtins.flatten(@total_sizes_per_cd_per_src) ) @total_count_to_download = packages_to_download( @total_pkg_count_per_cd_per_src ) @total_count_downloaded = 0 total_count_to_install = packages_to_install( @total_pkg_count_per_cd_per_src ) total = Ops.add(total_count_to_install, @total_count_to_download) @downloading_pct = Ops.divide( Ops.multiply(total == 0 ? 0 : 100, @total_count_to_download), total ) @init_pkg_data_complete = true # reset the history log SlideShow.inst_log = "" Builtins.y2milestone( "PackageSlideShow::InitPkgData() done; total_sizes_per_cd_per_src: %1", @total_sizes_per_cd_per_src ) Builtins.y2milestone( "PackageSlideShow::InitPkgData(): pkg: %1", @total_pkg_count_per_cd_per_src ) # RebuildDialog(true); nil end |
- (Object) ListSum(sizes)
Sum up all list items
164 165 166 167 168 169 170 171 |
# File '../../src/modules/PackageSlideShow.rb', line 164 def ListSum(sizes) sizes = deep_copy(sizes) sum = 0 Builtins.foreach(sizes) { |item| sum = Ops.add(sum, item) if item != -1 } sum end |
- (Object) ListSumCutOff(sizes, max_cutoff)
Sum up all positive list items, but cut off individual items at a maximum value. Negative return values indicate overflow of any individual item at "max_cutoff". In this case, the absolute value of the return value is "max_cutoff" * number of overflows. (e.g. >2hour + >2hours + 1:13:20 => >4hours
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File '../../src/modules/PackageSlideShow.rb', line 178 def ListSumCutOff(sizes, max_cutoff) sizes = deep_copy(sizes) overflow = 0 sum = 0 Builtins.foreach(sizes) do |item| if Ops.greater_than(item, 0) if Ops.greater_than(item, max_cutoff) overflow = Ops.add(overflow, 1) else sum = Ops.add(sum, item) end end end if Ops.greater_than(overflow, 0) sum = Ops.multiply(Ops.unary_minus(overflow), max_cutoff) end sum end |
- (Object) main
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 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 '../../src/modules/PackageSlideShow.rb', line 14 def main Yast.import "UI" Yast.import "Pkg" textdomain "packager" Yast.import "Slides" Yast.import "SlideShow" Yast.import "String" Yast.import "Mode" Yast.import "URL" Yast.import "Installation" @total_sizes_per_cd_per_src = [] # total sizes per inst-src: [ [42, 43, 44], [12, 13, 14] ] @remaining_sizes_per_cd_per_src = [] # remaining sizes @remaining_times_per_cd_per_src = [] # remaining times @inst_src_names = [] # a list of strings identifying each repository @total_pkg_count_per_cd_per_src = [] # number of pkgs per inst-src: [ [7, 5, 3], [2, 3, 4] ] @remaining_pkg_count_per_cd_per_src = [] # remaining number of pkgs @srcid_to_current_src_no = {} # the string is follwed by a media number, e.g. "Medium 1" @media_type = _("Medium %1") @total_size_installed = 0 @total_size_to_install = 0 @total_count_to_download = 0 @total_count_downloaded = 0 @downloading_pct = 0 @min_time_per_cd = 10 # const - minimum time displayed per CD if there is something to install @max_time_per_cd = 7200 # const - seconds to cut off predicted time (it's bogus anyway) @size_column = 1 # const - column number for remaining size per CD @pkg_count_column = 2 # const - column number for remaining number of packages per CD @time_column = 3 # const - column number for remaining time per CD @current_src_no = -1 # 1..n @current_cd_no = -1 # 1..n @next_src_no = -1 @next_cd_no = -1 @last_cd = false @total_cd_count = 0 @unit_is_seconds = false # begin with package sizes @bytes_per_second = 1 @init_pkg_data_complete = false @debug = false # more debugging info @provide_name = "" # currently downlaoded package name @provide_size = "" # currently downlaoded package size # package summary # package counters @installed_packages = 0 @updated_packages = 0 @removed_packages = 0 @total_downloaded = 0 @total_installed = 0 # package list (only used in installed system) @installed_packages_list = [] @updated_packages_list = [] @removed_packages_list = [] # integer avg_download_rate = 0; @current_provide_size = 0 @current_install_size = 0 @updating = false end |
- (Object) packages_to_download(src_mapping)
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
# File '../../src/modules/PackageSlideShow.rb', line 421 def packages_to_download(src_mapping) src_mapping = deep_copy(src_mapping) # src_mapping contains only enabled repos, get indices of the enabled repos here # and remap enabled index to the global repo ID enabled_sources = Pkg.SourceGetCurrent(true) Builtins.y2milestone("Packages to download input: %1", src_mapping) ret = 0 i = 0 Builtins.foreach(src_mapping) do |media_mapping| if Ops.greater_than(Builtins.size(media_mapping), 0) # check if the repository is remote repo_url = Ops.get_string( Pkg.SourceGeneralData(Ops.get(enabled_sources, i, -1)), "url", "" ) repo_schema = Builtins.tolower( Ops.get_string(URL.Parse(repo_url), "scheme", "") ) # iso repos get also downloaded according to experience; the addition is not a perfect # fix, but still improves the progress (bnc#724486) if Builtins.contains(["http", "https", "ftp", "sftp", "iso"], repo_schema) total = 0 Builtins.foreach(media_mapping) do |count| total = Ops.add(total, count) end Builtins.y2milestone( "Downloading %1 packages from remote repository %2", total, Ops.get(enabled_sources, i, -1) ) ret = Ops.add(ret, total) end end i = Ops.add(i, 1) end Builtins.y2milestone("Total number of packages to download: %1", ret) ret end |
- (Object) packages_to_install(src_mapping)
470 471 472 473 474 475 |
# File '../../src/modules/PackageSlideShow.rb', line 470 def packages_to_install(src_mapping) src_mapping = deep_copy(src_mapping) ret = ListSum(Builtins.flatten(src_mapping)) Builtins.y2milestone("Total number of packages to install: %1", ret) ret end |
- (Object) RecalcRemainingTimes(force_recalc)
Recalculate remaining times per CD based on package sizes remaining and data rate so far. Recalculation is only done each 'recalc_interval' seconds unless 'force_recalc' is set to 'true'.
658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
# File '../../src/modules/PackageSlideShow.rb', line 658 def RecalcRemainingTimes(force_recalc) if !force_recalc && Ops.less_than(Builtins.time, SlideShow.next_recalc_time) # Nothing to do (yet) - simply return return false end # Actually do recalculation elapsed = SlideShow.total_time_elapsed if Ops.greater_or_equal(SlideShow.start_time, 0) elapsed = Ops.subtract( Ops.add(elapsed, Builtins.time), SlideShow.start_time ) end if elapsed == 0 # Called too early - no calculation possible yet. # This happens regularly during initialization, so an error # message wouldn't be a good idea here. return false end # This is the real thing. real_bytes_per_second = Ops.divide(@total_size_installed, elapsed) # But this turns out to be way to optimistic - RPM gets slower and # slower while installing. So let's add some safety margin to make # sure initial estimates are on the pessimistic side - the # installation being faster than initially estimated will be a # pleasant surprise to the user. Most users don't like it the other # way round. # # The "pessimistic factor" progressively decreases as the installation # proceeds. It begins with about 1.7, i.e. the data transfer rate is # halved to what it looks like initially. It decreases to 1.0 towards # the end. pessimistic_factor = 1.0 if Ops.greater_than(@total_size_to_install, 0) pessimistic_factor = Ops.subtract( 1.7, Ops.divide( Builtins.tofloat(@total_size_installed), Builtins.tofloat(@total_size_to_install) ) ) end @bytes_per_second = Builtins.tointeger( Ops.add( Ops.divide( Builtins.tofloat(real_bytes_per_second), pessimistic_factor ), 0.5 ) ) @bytes_per_second = 1 if Ops.less_than(@bytes_per_second, 1) @remaining_times_per_cd_per_src = [] # Recalculate remaining times for the individual CDs Builtins.foreach(@remaining_sizes_per_cd_per_src) do |remaining_sizes_list| remaining_times_list = [] remaining_time = -1 Builtins.foreach(remaining_sizes_list) do |remaining_size| remaining_time = remaining_size if Ops.greater_than(remaining_size, 0) remaining_time = Ops.divide(remaining_size, @bytes_per_second) if Ops.less_than(remaining_time, @min_time_per_cd) # It takes at least this long for the CD drive to spin up and # for RPM to do _anything_. Times below this values are # ridiculously unrealistic. remaining_time = @min_time_per_cd elsif Ops.greater_than(remaining_time, @max_time_per_cd) # clip off at 2 hours # When data throughput goes downhill (stalled network connection etc.), # cut off the predicted time at a reasonable maximum. remaining_time = @max_time_per_cd end end remaining_times_list = Builtins.add( remaining_times_list, remaining_time ) end @remaining_times_per_cd_per_src = Builtins.add( @remaining_times_per_cd_per_src, remaining_times_list ) end # Recalculate slide interval if Slides.HaveSlides = Ops.subtract( Ops.subtract(Builtins.size(Slides.), SlideShow.), 1 ) if Ops.greater_than(, 0) # The remaining time for the rest of the slides depends on the # remaining time for the current CD only: This is where the # slide images and texts reside. Normally, only CD1 has slides # at all, i.e. the slide show must be finished when CD1 is # done. # # In addition to that, take elapsed time for current slide # into account so all slides get about the same time. time_remaining = Ops.subtract( Ops.add( Ops.get( @remaining_times_per_cd_per_src, [ Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1) ], 1 ), Builtins.time ), SlideShow. ) SlideShow. = Ops.divide( time_remaining, ) Builtins.y2debug( "New slide interval: %1 - slides remaining: %2 - remaining time: %3", SlideShow., , time_remaining ) if Ops.less_than( SlideShow., SlideShow. ) SlideShow. = SlideShow. Builtins.y2debug( "Resetting slide interval to min slide interval: %1", SlideShow. ) end if Ops.greater_than( SlideShow., SlideShow. ) SlideShow. = SlideShow. Builtins.y2debug( "Resetting slide interval to max slide interval: %1", SlideShow. ) end end end SlideShow.next_recalc_time = Ops.add( Builtins.time, SlideShow.recalc_interval ) true end |
- (Object) ResetPackageSummary
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File '../../src/modules/PackageSlideShow.rb', line 80 def ResetPackageSummary @installed_packages = 0 @updated_packages = 0 @removed_packages = 0 @total_downloaded = 0 @total_installed = 0 # avg_download_rate = 0; @installed_packages_list = [] @updated_packages_list = [] @removed_packages_list = [] # temporary values @current_provide_size = 0 @current_install_size = 0 @updating = false nil end |
- (Object) SanityCheck(silent)
Perform sanity check for correct initialzation etc.
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File '../../src/modules/PackageSlideShow.rb', line 328 def SanityCheck(silent) return true # FIXME! if !@init_pkg_data_complete if !silent Builtins.y2error( "PackageSlideShow::SanityCheck(): Slide show not correctly initialized: " + "PackageSlideShow::InitPkgData() never called!" ) end return false end if Ops.less_than(@current_src_no, 1) || Ops.less_than(@current_cd_no, 1) # nothing to install but something is going to be deleted, so it's OK if Pkg.IsAnyResolvable(:package, :to_remove) return true elsif !silent Builtins.y2error( -1, "PackageSlideShow::SanityCheck(): Illegal values for current_src_no (%1) or current_cd_no (%2)", @current_src_no, @current_cd_no ) Builtins.y2milestone("total sizes: %1", @total_sizes_per_cd_per_src) end return false end true end |
- (Object) SetCurrentCdNo(src_no, cd_no)
Set the current repository and CD number. Must be called for each CD change. src_no: 1...n cd_no: 1...n
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
# File '../../src/modules/PackageSlideShow.rb', line 619 def SetCurrentCdNo(src_no, cd_no) if cd_no == 0 Builtins.y2milestone("medium number 0, using medium number 1") cd_no = 1 end Builtins.y2milestone("SetCurrentCdNo() - src: %1 , CD: %2", src_no, cd_no) @current_src_no = Ops.get(@srcid_to_current_src_no, src_no, -1) @current_cd_no = cd_no SlideShow.CheckForSlides FindNextMedia() if Slides.HaveSlides && Slides.HaveSlideSupport if !SlideShow.HaveSlideWidget SlideShow.RebuildDialog SlideShow.SwitchToDetailsView if SlideShow.user_switched_to_details end if !SlideShow.user_switched_to_details # Don't override explicit user request! SlideShow.SwitchToSlideView end else SlideShow.RebuildDialog if !SlideShow.ShowingDetails end nil end |
- (Object) SetMediaType(new_media_type)
set media type “CD” or “DVD”
154 155 156 157 158 159 160 |
# File '../../src/modules/PackageSlideShow.rb', line 154 def SetMediaType(new_media_type) Builtins.y2warning( "PackageSlideShow::SetMediaType() is obsoled, do not use!" ) nil end |
- (Object) SlideDeltaApplyStart(pkg_name)
1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 |
# File '../../src/modules/PackageSlideShow.rb', line 1449 def SlideDeltaApplyStart(pkg_name) return if !SanityCheck(false) return if !SlideShow.ShowingDetails SlideShow.SubProgress(0, pkg_name) SlideShow.AppendMessageToInstLog( Builtins.sformat(_("Applying delta RPM: %1"), pkg_name) ) nil end |
- (Object) SlideDisplayDone(pkg_name, pkg_size, deleting)
package start display update - this is called at the end of a new package
1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 |
# File '../../src/modules/PackageSlideShow.rb', line 1277 def SlideDisplayDone(pkg_name, pkg_size, deleting) if !deleting SubtractPackageSize(pkg_size) if SwitchToSecondsIfNecessary() || RecalcRemainingTimes(false) # no forced recalculation Builtins.y2debug("Updating progress for all CDs") UpdateAllCdProgress(false) else UpdateCurrentCdProgress(false) end UpdateTotalProgress(false) # Update global progress bar DisplayGlobalProgress() if @updating @updated_packages = Ops.add(@updated_packages, 1) if Mode.normal @updated_packages_list = Builtins.add( @updated_packages_list, pkg_name ) end else @installed_packages = Ops.add(@installed_packages, 1) if Mode.normal @installed_packages_list = Builtins.add( @installed_packages_list, pkg_name ) end end @total_installed = Ops.add(@total_installed, @current_install_size) else @removed_packages = Ops.add(@removed_packages, 1) if Mode.normal @removed_packages_list = Builtins.add( @removed_packages_list, pkg_name ) end end nil end |
- (Object) SlideDisplayStart(pkg_name, pkg_location, pkg_summary, pkg_size, deleting)
package start display update - this is called at the beginning of a new package
1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 |
# File '../../src/modules/PackageSlideShow.rb', line 1341 def SlideDisplayStart(pkg_name, pkg_location, pkg_summary, pkg_size, deleting) return if !SanityCheck(false) # remove path pkg_filename = StripPath(pkg_location) Builtins.y2milestone("pkg_name: %1", pkg_name) if deleting pkg_size = -1 # This is a kind of misuse of insider knowledge: If there are packages to delete, this # deletion comes first, and only then packages are installed. This, however, greatly # distorts the estimated times based on data throughput so far: While packages are # deleted, throughput is zero, and estimated times rise to infinity (they are cut off # at max_time_per_cd to hide this). So we make sure the time spent deleting packages is # not counted for estimating remaining times - reset the timer. # # Note: This will begin to fail when some day packages are deleted in the middle of the # installaton process. SlideShow.ResetTimer end pkg_summary = "" if pkg_summary == nil msg = "" if deleting # Heading for the progress bar for the current package # while it is deleted. "%1" is the package name. msg = Builtins.sformat(_("Deleting %1"), pkg_name) else @updating = Pkg.PkgInstalled(pkg_name) # package installation - summary text # %1 is RPM name, %2 is installed (unpacked) size (e.g. 6.20MB) msg = Builtins.sformat( _("Installing %1 (installed size %2)"), pkg_filename, String.FormatSize(pkg_size) ) @current_install_size = pkg_size end # # Update package progress bar # SlideShow.SubProgress(0, msg) # Update global progress bar DisplayGlobalProgress() # # Update (user visible) installation log # SlideShow.AppendMessageToInstLog(msg) # # Update the current slide if applicable # SlideShow.ChangeSlideIfNecessary if SlideShow.ShowingSlide nil end |
- (Object) SlideGenericProvideStart(pkg_name, sz, pattern, remote)
1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 |
# File '../../src/modules/PackageSlideShow.rb', line 1410 def SlideGenericProvideStart(pkg_name, sz, pattern, remote) return if !SanityCheck(false) return if !SlideShow.ShowingDetails provide_msg = "" if remote @provide_name = pkg_name @provide_size = String.FormatSize(sz) provide_msg = Builtins.sformat( _("Downloading %1 (download size %2)"), @provide_name, @provide_size ) else provide_msg = pkg_name end SlideShow.SubProgress(0, provide_msg) # # Update (user visible) installation log # for remote download only # return if !remote Builtins.y2milestone("Package '%1' is remote", pkg_name) # message in the installatino log, %1 is package name, # %2 is package size SlideShow.AppendMessageToInstLog( Builtins.sformat(pattern, pkg_name, String.FormatSize(sz)) ) nil end |
- (Object) SlideProvideStart(pkg_name, sz, remote)
Package providal start
1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 |
# File '../../src/modules/PackageSlideShow.rb', line 1464 def SlideProvideStart(pkg_name, sz, remote) @current_provide_size = remote ? sz : 0 if remote # message in the installatino log, %1 is package name, # %2 is package size SlideGenericProvideStart( pkg_name, sz, _("Downloading %1 (download size %2)"), remote ) end nil end |
- (String) StripPath(pkg_name)
Get package file name from path
139 140 141 142 143 144 145 146 147 148 149 150 |
# File '../../src/modules/PackageSlideShow.rb', line 139 def StripPath(pkg_name) return nil if pkg_name == nil file_pos = Builtins.findlastof(pkg_name, "/") if file_pos != nil && Ops.greater_than(file_pos, 0) # return just the file name pkg_name = Builtins.substring(pkg_name, Ops.add(file_pos, 1)) end pkg_name end |
- (Object) StripReleaseNo(pkg_name)
Get version info for a package (without build no.)
123 124 125 126 127 128 129 130 131 132 |
# File '../../src/modules/PackageSlideShow.rb', line 123 def StripReleaseNo(pkg_name) build_no_pos = Builtins.findlastof(pkg_name, "-") # find trailing build no. if build_no_pos != nil && Ops.greater_than(build_no_pos, 0) # cut off trailing build no. pkg_name = Builtins.substring(pkg_name, 0, build_no_pos) end pkg_name end |
- (Object) SubtractPackageSize(pkg_size)
Update internal bookkeeping: subtract size of one package from the global list of remaining sizes per CD
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# File '../../src/modules/PackageSlideShow.rb', line 362 def SubtractPackageSize(pkg_size) remaining = Ops.get( @remaining_sizes_per_cd_per_src, [Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1)], 1 ) remaining = Ops.subtract(remaining, pkg_size) @total_size_installed = Ops.add(@total_size_installed, pkg_size) if Ops.less_or_equal(remaining, 0) # -1 is the indicator for "done with this CD" - not to be # confused with 0 for "nothing to install from this CD". remaining = -1 end Ops.set( @remaining_sizes_per_cd_per_src, [Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1)], remaining ) Ops.set( @remaining_pkg_count_per_cd_per_src, [Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1)], Ops.subtract( Ops.get( @remaining_pkg_count_per_cd_per_src, [Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1)], 0 ), 1 ) ) if @unit_is_seconds seconds = 0 if Ops.greater_than(remaining, 0) && Ops.greater_than(@bytes_per_second, 0) seconds = Ops.divide(remaining, @bytes_per_second) end Ops.set( @remaining_times_per_cd_per_src, [Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1)], seconds ) end if @debug Builtins.y2milestone( "SubtractPackageSize( %1 ) -> %2", pkg_size, @remaining_sizes_per_cd_per_src ) end nil end |
- (Object) SwitchToSecondsIfNecessary
Switch unit to seconds if necessary and recalc everything accordingly.
837 838 839 840 841 842 843 844 845 846 847 848 849 850 |
# File '../../src/modules/PackageSlideShow.rb', line 837 def SwitchToSecondsIfNecessary if @unit_is_seconds || Ops.less_than( Builtins.time, Ops.add(SlideShow.start_time, SlideShow.initial_recalc_delay) ) return false # no need to switch end RecalcRemainingTimes(true) # force recalculation @unit_is_seconds = true true # just switched end |
- (Object) TotalInstalledSize
219 220 221 |
# File '../../src/modules/PackageSlideShow.rb', line 219 def TotalInstalledSize Ops.subtract(@total_size_to_install, TotalRemainingSize()) end |
- (Object) TotalRemainingPkgCount
214 215 216 |
# File '../../src/modules/PackageSlideShow.rb', line 214 def TotalRemainingPkgCount ListSum(Builtins.flatten(@remaining_pkg_count_per_cd_per_src)) end |
- (Object) TotalRemainingSize
201 202 203 |
# File '../../src/modules/PackageSlideShow.rb', line 201 def TotalRemainingSize ListSum(Builtins.flatten(@remaining_sizes_per_cd_per_src)) end |
- (Object) TotalRemainingTime
206 207 208 209 210 211 |
# File '../../src/modules/PackageSlideShow.rb', line 206 def TotalRemainingTime ListSumCutOff( Builtins.flatten(@remaining_times_per_cd_per_src), @max_time_per_cd ) end |
- (Object) UpdateAllCdProgress(silent_check)
Update progress widgets for all CDs. Uses global statistics variables.
1249 1250 1251 1252 1253 1254 1255 1256 1257 |
# File '../../src/modules/PackageSlideShow.rb', line 1249 def UpdateAllCdProgress(silent_check) return if !SanityCheck(silent_check) RecalcRemainingTimes(true) if @unit_is_seconds # force SlideShow.UpdateTable(CdStatisticsTableItems()) nil end |
- (Object) UpdateCurrentCdProgress(silent_check)
Update progress widgets for the current CD: Label and ProgressBar. Use global statistics variables for that.
863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 |
# File '../../src/modules/PackageSlideShow.rb', line 863 def UpdateCurrentCdProgress(silent_check) return if !SanityCheck(silent_check) return if !UI.WidgetExists(:cdStatisticsTable) # # Update table entries for current CD # remaining = Ops.get( @remaining_sizes_per_cd_per_src, [Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1)], 0 ) UI.ChangeWidget( Id(:cdStatisticsTable), term( :Item, Builtins.sformat( "cd(%1,%2)", Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1) ), @size_column ), FormatRemainingSize(remaining) ) UI.ChangeWidget( Id(:cdStatisticsTable), term( :Item, Builtins.sformat( "cd(%1,%2)", Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1) ), @pkg_count_column ), FormatRemainingCount( Ops.get( @remaining_pkg_count_per_cd_per_src, [Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1)], 0 ) ) ) if @unit_is_seconds # Convert 'remaining' from size (bytes) to time (seconds) remaining = Ops.divide(remaining, @bytes_per_second) remaining = 0 if Ops.less_or_equal(remaining, 0) if Ops.greater_than(remaining, @max_time_per_cd) # clip off at 2 hours # When data throughput goes downhill (stalled network connection etc.), # cut off the predicted time at a reasonable maximum. remaining = Ops.unary_minus(@max_time_per_cd) end UI.ChangeWidget( Id(:cdStatisticsTable), term( :Item, Builtins.sformat( "cd(%1,%2)", Ops.subtract(@current_src_no, 1), Ops.subtract(@current_cd_no, 1) ), @time_column ), FormatTimeShowOverflow(remaining) ) end # # Update "total" table entries # UI.ChangeWidget( Id(:cdStatisticsTable), term(:Item, "total", @size_column), FormatRemainingSize(TotalRemainingSize()) ) UI.ChangeWidget( Id(:cdStatisticsTable), term(:Item, "total", @pkg_count_column), FormatRemainingCount(TotalRemainingPkgCount()) ) if @unit_is_seconds UI.ChangeWidget( Id(:cdStatisticsTable), term(:Item, "total", @time_column), FormatTimeShowOverflow(TotalRemainingTime()) ) end nil end |
- (Object) UpdateCurrentPackageProgress(pkg_percent)
Progress display update This is called via the packager's progress callbacks.
1144 1145 1146 1147 1148 |
# File '../../src/modules/PackageSlideShow.rb', line 1144 def UpdateCurrentPackageProgress(pkg_percent) SlideShow.SubProgress(pkg_percent, nil) nil end |
- (Object) UpdateCurrentPackageRateProgress(pkg_percent, bps_avg, bps_current)
update the download rate
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 |
# File '../../src/modules/PackageSlideShow.rb', line 1151 def UpdateCurrentPackageRateProgress(pkg_percent, bps_avg, bps_current) # avg_download_rate = bps_avg; return if !SlideShow.ShowingDetails new_text = nil # no update of the label if Ops.greater_than(bps_current, 0) # do not show the average download rate if the space is limited if SlideShow.textmode && Ops.less_than(SlideShow.display_width, 100) bps_avg = -1 end new_text = String.FormatRateMessage( Ops.add(@provide_name, " - %1"), bps_avg, bps_current ) new_text = Builtins.sformat( _("Downloading %1 (download size %2)"), new_text, @provide_size ) end SlideShow.SubProgress(pkg_percent, new_text) nil end |
- (Object) UpdateTotalProgress(silent_check)
Update progress widgets
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 |
# File '../../src/modules/PackageSlideShow.rb', line 1005 def UpdateTotalProgress(silent_check) total_size_to_install_kB = Ops.shift_right(@total_size_to_install, 10) # avoid division by zero if Ops.less_or_equal(total_size_to_install_kB, 0) total_size_to_install_kB = 1 end # update the overall progress value (download + installation) UpdateTotalProgressValue() UpdateCurrentCdProgress(silent_check) if UI.WidgetExists(:nextMedia) nextMedia = FormatNextMedia() if nextMedia != "" || @last_cd UI.ChangeWidget(:nextMedia, :Value, nextMedia) UI.RecalcLayout @last_cd = false end end nil end |
- (Object) UpdateTotalProgressValue
update the overall progress value (download + installation)
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 |
# File '../../src/modules/PackageSlideShow.rb', line 968 def UpdateTotalProgressValue total_progress = 0 if @total_count_to_download == 0 # no package to download, just use the install size total_progress = Ops.divide( Ops.multiply(TotalInstalledSize(), 100), @total_size_to_install ) else # compute the total progress (use both download and installation size) total_progress = Ops.add( Ops.divide( Ops.multiply(@total_count_downloaded, @downloading_pct), @total_count_to_download ), Ops.divide( Ops.multiply( TotalInstalledSize(), Ops.subtract(100, @downloading_pct) ), @total_size_to_install ) ) end Builtins.y2debug( "Total package installation progress: %1%%", total_progress ) SlideShow.StageProgress(total_progress, nil) nil end |