Module: Yast::HwinfoRoutinesInclude
- Defined in:
- ../../src/include/hwinfo/routines.rb
Instance Method Summary (collapse)
- - (Object) add_hex_prefix(_in)
-
- (String) classtostring(a, m)
Translate subclass identification of the device.
-
- (Array) expandTree(node)
Recursively converts (scalar/nested) lists and maps to tree datastructure.
-
- (String) get_representant(m)
if expandTree function tries to explore list, it should use some label for each item.
- - (Object) has_hex_prefix(_in)
-
- (String) icon(str)
icon for path - looks to the translation table and returns value.
- - (Object) initialize_hwinfo_routines(include_target)
- - (Object) modules(val)
-
- (String) mount_device(device)
Mount specified device.
- - (Object) remove_hex_prefix(_in)
-
- (String) resolution(a, m)
reads values from map and creates formatted label for monitor resolution data.
-
- (Boolean) save_hwinfo(file)
Save hwinfo output to the specified file.
-
- (Boolean) save_hwinfo_to_file(target_file_name)
Save hwinfo output to the specified file, progress popup is displayed.
-
- (Boolean) scalar(node)
evals to true if given value is scalar (not map or term or list).
-
- (String) trans_bool(b)
translate boolean to Yes/No.
-
- (String) trans_str(str)
translate string - looks to the translation table and returns value.
-
- (Hash) translate_hw_entry(hw)
tries to determine hardware name by class_id and sub_class_id and substitues them in given map.
-
- (Boolean) umount_device(mount_point)
Unmount device.
Instance Method Details
- (Object) add_hex_prefix(_in)
1121 1122 1123 1124 1125 1126 1127 |
# File '../../src/include/hwinfo/routines.rb', line 1121 def add_hex_prefix(_in) if _in == nil || _in == "" return "" else return !has_hex_prefix(_in) ? Ops.add("0x", _in) : _in end end |
- (String) classtostring(a, m)
Translate subclass identification of the device
844 845 846 847 848 849 |
# File '../../src/include/hwinfo/routines.rb', line 844 def classtostring(a, m) a = deep_copy(a) m = deep_copy(m) trans = translate_hw_entry(m) Ops.get_string(trans, "sub_class_id", "") end |
- (Array) expandTree(node)
Recursively converts (scalar/nested) lists and maps to tree datastructure
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 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 1002 1003 1004 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 1030 1031 1032 1033 1034 1035 |
# File '../../src/include/hwinfo/routines.rb', line 947 def (node) node = deep_copy(node) return [] if node == nil # workaround for bug #31144 - don't visualize list # with only one map item if Ops.is_list?(node) && Builtins.size(Convert.to_list(node)) == 1 node_list = Convert.to_list(node) if Ops.is_map?(Ops.get(node_list, 0)) tmp = Builtins.eval(Ops.get_map(node_list, 0, {})) # if map has "model" key then don't flatten list, # device model name would be removed from the tree # when there is only one device in a device category node = deep_copy(tmp) if !Builtins.haskey(tmp, "model") end end # if node is scalar, we just return the new item. return [Item(trans_str(Builtins.sformat("%1", node)))] if scalar(node) if Ops.is_list?(node) # if node is list ... lout = [] q = Builtins.size(Convert.to_list(node)) pos = 0 Builtins.foreach(Convert.to_list(node)) do |e| if scalar(e) if e != nil lout = Builtins.add(lout, Item(Builtins.sformat("%1", e))) end else lab = UI.Glyph(:ArrowRight) if Ops.is(e, "map <string, any>") # ... create label for each item ... s = get_representant( Convert.convert(e, :from => "any", :to => "map <string, any>") ) lab = s if s != "" end lout = Builtins.add(lout, Item(lab, (e))) end # ... and add it to item list pos = Ops.add(pos, 1) end return deep_copy(lout) end if Ops.is_map?(node) # if node is map ... node_map = translate_hw_entry( Convert.convert(node, :from => "any", :to => "map <string, any>") ) ltmp = [] Builtins.foreach(node_map) do |key, v| # haha, hack! we need to translate the 'modules' entry into some more readable form... # unfortunatelly 'modules' is used in several places and in different meaings... if key == "modules" && Ops.is_list?(v) v = modules( Convert.convert(v, :from => "any", :to => "list <list <string>>") ) end # ... explore all pairs if scalar(v) || v == {} || v == [] ltmp = Builtins.add( ltmp, Item(Builtins.sformat("%1: %2", trans_str(key), trans_bool(v))) ) elsif v == [""] ltmp = Builtins.add( ltmp, Item(Builtins.sformat("%1", trans_str(key))) ) else ltmp = Builtins.add( ltmp, Item(trans_str(Builtins.sformat("%1", key)), (v)) ) end end # ... and finally sort the items alphabetically return Builtins.sort(ltmp) end [] end |
- (String) get_representant(m)
if expandTree function tries to explore list, it should use some label for each item. it tree items are maps, this function decides which value from map will be used as label
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 |
# File '../../src/include/hwinfo/routines.rb', line 905 def get_representant(m) m = deep_copy(m) out = "" i = 0 # search the 'order' table while Ops.less_than(i, Builtins.size(@representant_order)) key_name = Ops.get(@representant_order, i, "") if Builtins.haskey(m, key_name) if key_name == "start" out = Builtins.tohexstring(Ops.get_integer(m, key_name, 0)) elsif key_name == "modules" # Linux kernel modules (drivers) out = _("Modules") elsif key_name == "width" out = resolution("dummy", m) elsif key_name == "sub_class_id" out = classtostring("dummy", m) elsif key_name == "device" out = Ops.get_string(m, key_name, "") if Builtins.haskey(m, "dev_name") device = Ops.get_string(m, "dev_name", "") if device != "" # tree node string - %1 is device name, %2 is /dev file out = Builtins.sformat(_("%1 (%2)"), out, device) end end else out = trans_str(Builtins.sformat("%1", Ops.get(m, key_name))) end break end i = Ops.add(i, 1) end out end |
- (Object) has_hex_prefix(_in)
1107 1108 1109 1110 1111 1112 1113 |
# File '../../src/include/hwinfo/routines.rb', line 1107 def has_hex_prefix(_in) return false if Ops.less_than(Builtins.size(_in), 2) # check whether string has hex prefix (0x or 0X) start = Builtins.substring(_in, 0, 2) start == "0x" || start == "0X" end |
- (String) icon(str)
icon for path - looks to the translation table and returns value
864 865 866 867 868 869 870 |
# File '../../src/include/hwinfo/routines.rb', line 864 def icon(str) if !Builtins.haskey(@trans_table, str) Builtins.y2warning("Cannot find icon for string '%1'", str) return nil end Ops.get(@trans_table, [str, 1]) end |
- (Object) initialize_hwinfo_routines(include_target)
11 12 13 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 79 80 81 82 83 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 127 128 129 130 131 132 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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 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 318 319 320 321 322 323 324 325 326 327 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 358 359 360 361 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 420 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 469 470 471 472 473 474 475 476 477 478 479 480 481 482 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 565 566 567 568 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 613 614 615 616 617 618 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 648 649 650 651 652 653 654 655 656 657 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 |
# File '../../src/include/hwinfo/routines.rb', line 11 def initialize_hwinfo_routines(include_target) Yast.import "UI" textdomain "tune" Yast.import "Report" Yast.include include_target, "hwinfo/classnames.rb" # translation table- key is replaced by value on it's way to ui # must be done this way, because keys are machine-generated @trans_table = Builtins.eval( { # tree node string "architecture" => [ _("Architecture"), "yast-hardware" ], # tree node string - means "hardware bus" "bus" => [ _("Bus"), "yast-hardware" ], # tree node string - means "hardware bus ID" "bus_id" => [ _("Bus ID"), "yast-hardware" ], # tree node string "cache" => [ _("Cache"), "yast-hardware" ], # tree node string "card_type" => [ _("Card Type"), "yast-hardware" ], # tree node string "cardtype" => [ _("Card Type"), "yast-hardware" ], # tree node string - means "class of hardware" "class_id" => [ _("Class"), "yast-hardware" ], # tree node string "cdtype" => [ _("CD Type"), "yast-cd" ], # tree node string "dev_name" => [ _("Device Name"), "yast-hardware" ], # tree node string "dev_num" => [ _("Device Numbers"), "yast-hardware" ], # tree node string "sysfs_id" => [ _("Sysfs ID"), "yast-hardware" ], # tree node string "device" => [ _("Device"), "yast-hardware" ], # tree node string "device_id" => [ _("Device Identifier"), "yast-hardware" ], # tree node string - means "hardware drivers" "drivers" => [ _("Drivers"), "yast-hardware" ], # tree node string - means "hardware driver" "driver" => [ _("Driver"), "yast-hardware" ], # tree node string "type" => [ _("Type"), "yast-hardware" ], # tree node string "major" => [ _("Major"), "yast-partitioning" ], # tree node string "minor" => [ _("Minor"), "yast-partitioning" ], # tree node string "range" => [ _("Range"), "yast-hardware" ], # tree node string (System Management BIOS) "smbios" => [ _("SMBIOS"), "yast-hardware" ], # tree node string "prog_if" => [ _("Interface"), "yast-hardware" ], # tree node string "resource" => [ _("Resources"), "yast-hardware" ], # tree node string "requires" => [ _("Requires"), "yast-hardware" ], # tree node string "rev" => [ _("Revision"), "yast-hardware" ], # tree node string - location of hardware in the machine "slot_id" => [ _("Slot ID"), "yast-hardware" ], # tree node string "length" => [ _("Length"), "yast-hardware" ], # tree node string "width" => [ _("Width"), "yast-hardware" ], # tree node string "height" => [ _("Height"), "yast-hardware" ], # tree node string "active" => [ _("Active"), "yast-hardware" ], # tree node string "dev_names" => [ _("Device Names"), "yast-hardware" ], # tree node string (number of colors) "color" => [ _("Colors"), "yast-hardware" ], # tree node string (harddisk parameter) "disk_log_geo" => [ _("Logical Geometry"), "yast-hardware" ], # tree node string "count" => [ _("Count"), "yast-hardware" ], # tree node string "mode" => [ _("Mode"), "yast-hardware" ], # tree node string (interrupt request) "irq" => [ _("IRQ"), "yast-hardware" ], # tree node string "io" => [ _("IO Port"), "yast-hardware" ], # tree node string "mem" => [ _("Memory"), "yast-hardware" ], # tree node string (direct memory access) "dma" => [ _("DMA"), "yast-hardware" ], # tree node string "bus_hwcfg" => [ _("Hwcfg Bus"), "yast-hardware" ], # tree node string "sysfs_bus_id" => [ _("Sysfs ID"), "yast-hardware" ], # tree node string "parent_unique_key" => [ _("Parent Unique ID"), "yast-hardware" ], # tree node string "udi" => [ _("UDI"), "yast-hardware" ], # tree node string "uniqueid" => [ _("Unique ID"), "yast-x11" ], # tree node string (monitor parameter) "vfreq" => [ _("Vertical Frequency"), "yast-x11" ], # tree node string (monitor parameter) "max_hsync" => [ _("Max. Horizontal Frequency"), "yast-x11" ], # tree node string (monitor parameter) "max_vsync" => [ _("Max. Vertical Frequency"), "yast-x11" ], # tree node string (monitor parameter) "min_hsync" => [ _("Min. Horizontal Frequency"), "yast-x11" ], # tree node string (monitor parameter) "min_vsync" => [ _("Min. Vertical Frequency"), "yast-x11" ], # tree node string "dvd" => [ _("DVD"), "yast-cdrom" ], # tree node string "driver_module" => [ _("Kernel Driver"), "yast-hardware" ], # tree node string "hwaddr" => [ _("HW Address"), "yast-hardware" ], # tree node string "bios_id" => [ _("BIOS ID"), "yast-hardware" ], # tree node string "enabled" => [ _("Enabled"), "yast-hardware" ], # tree node string (monitor resolution e.g. 1280x1024) "monitor_resol" => [ _("Resolution"), "yast-x11" ], # tree node string "size" => [ _("Size"), "yast-x11" ], # tree node string "old_unique_key" => [ _("Old Unique Key"), "yast-x11" ], # tree node string "sub_class_id" => [ _("Class (spec)"), "yast-x11" ], # tree node string "sub_device" => [ _("Device (spec)"), "yast-x11" ], # tree node string "sub_device_id" => [ _("Device Identifier (spec)"), "yast-x11" ], # tree node string "sub_vendor" => [ _("Subvendor"), "yast-x11" ], # tree node string "sub_vendor_id" => [ _("Subvendor Identifier"), "yast-x11" ], # tree node string "unique_key" => [ _("Unique Key"), "yast-x11" ], # tree node string "vendor" => [ _("Vendor"), "yast-x11" ], # tree node string "vendor_id" => [ _("Vendor Identifier"), "yast-x11" ], # tree node string "bios_video" => [ _("BIOS Video"), "yast-x11" ], # tree node string "boot_arch" => [ _("Boot Architecture"), "yast-bootloader" ], # tree node string "boot_disk" => [ _("Boot Disk"), "yast-bootloader" ], # tree node string "block" => [ _("Block Devices"), "yast-disk" ], # tree node string "redasd" => [ _("DASD Disks"), "yast-dasd" ], # tree node string "cdrom" => [ _("CD-ROM"), "yast-cdrom" ], # tree node string "cpu" => [ _("CPU"), "yast-hardware" ], # tree node string "disk" => [ _("Disk"), "yast-disk" ], # tree node string "display" => [ _("Display"), "yast-x11" ], # tree node string "floppy" => [ _("Floppy Disk"), "yast-floppy" ], # tree node string "framebuffer" => [ _("Framebuffer"), "yast-x11" ], # tree node string (powermanagement) "has_apm" => [ _("Has APM"), "yast-power-management" ], # tree node string "has_pcmcia" => [ _("Has PCMCIA"), "yast-hardware" ], # tree node string (multiprocessing) "has_smp" => [ _("Has SMP"), "yast-hardware" ], # tree node string - UML = User Mode Linux "is_uml" => [ _("UML System"), "yast-vm-management" ], # tree node string "ihw_data" => [ _("Hardware Data"), "yast-hardware" ], # tree node string "isdn" => [ _("ISDN"), "yast-isdn" ], # tree node string "keyboard" => [ _("Keyboard"), "yast-keyboard" ], # tree node string "monitor" => [ _("Monitor"), "yast-x11" ], # tree node string "netdev" => [ _("Network Devices"), "yast-lan" ], # tree node string "netif" => [ _("Network Interface"), "yast-lan" ], # tree node string "printer" => [ _("Printer"), "yast-printer" ], # tree node string "modem" => [ _("Modem"), "yast-modem" ], # tree node string "sound" => [ _("Sound"), "yast-sound" ], # tree node string "storage" => [ _("Storage Media"), "yast-disk" ], # tree node string "system" => [ _("System"), "yast-hardware" ], # tree node string "tv" => [ _("TV Card"), "yast-tv" ], # tree node string "dvb" => [ _("DVB Card"), "yast-tv" ], # tree node string "usb_type" => [ _("USB Type"), "yast-hardware" ], # tree node string "version" => [ _("Version"), "yast-hardware" ], # tree node string - memory (RAM) information "memory" => [ _("Memory"), "yast-hardware" ], # tree node string "netcard" => [ _("Network Card"), "yast-lan" ], # tree node string "bios" => [ _("BIOS"), "yast-hardware" ], # tree node string "fbdev" => [ _("Framebuffer Device"), "yast-x11" ], # tree node string - bus type "ide" => [ _("IDE"), "yast-disk" ], # tree node string - bus type "pci" => [ _("PCI"), "yast-hardware" ], # tree node string - bus type "usb" => [ _("USB"), "yast-hardware" ], # tree node string - bus type "isapnp" => [ _("ISA PnP"), "yast-hardware" ], # tree node "usbctrl" => [ _("USB Controller"), "yast-hardware" ], # tree node "hub" => [ _("USB Hub"), "yast-hardware" ], # tree node "ieee1394ctrl" => [ _("IEEE1394 Controller"), "yast-hardware" ], # tree node "scsi" => [ _("SCSI"), "yast-hardware" ], # tree node "scanner" => [ _("Scanner"), "yast-scanner" ], # tree node "mouse" => [_("Mouse"), "yast-mouse"], # tree node "joystick" => [ _("Joystick"), "yast-joystick" ], # tree node "braille" => [ _("Braille Display"), "yast-hardware" ], # tree node "chipcard" => [ _("Chipcard Reader"), "yast-hardware" ], # tree node - Digital camera or WebCam "camera" => [ _("Camera"), "yast-hardware" ], # Point-to-Point Protocol Over Ethernet "pppoe" => [ _("PPP over Ethernet"), "yast-dsl" ], # tree node string - CPU information "bogomips" => [ _("Bogus Millions of Instructions Per Second"), "yast-hardware" ], # tree node string - CPU information "cache" => [ _("Cache"), "yast-hardware" ], # tree node string - CPU information "coma_bug" => [ _("Coma Bug"), "yast-hardware" ], # tree node string - CPU information "f00f_bug" => [ _("f00f Bug"), "yast-hardware" ], # tree node string - CPU information "cpuid_level" => [ _("CPU ID Level"), "yast-hardware" ], # tree node string - CPU information "mhz" => [ _("Frequency"), "yast-hardware" ], # tree node string - CPU information "fdiv_bug" => [ _("Floating point division bug"), "yast-hardware" ], # tree node string - CPU information "flags" => [ _("Flags"), "yast-hardware" ], # tree node string - CPU information "fpu" => [ _("Floating Point Unit"), "yast-hardware" ], # tree node string - CPU information "fpu_exception" => [ _("Floating Point Unit Exception"), "yast-hardware" ], # tree node string - CPU information "hlt_bug" => [ _("Halt Bug"), "yast-hardware" ], # tree node string - CPU information "processor" => [ _("Processor"), "yast-hardware" ], # tree node string - CPU information "stepping" => [ _("Stepping"), "yast-hardware" ], # tree node string - CPU information "vendor_id" => [ _("Vendor Identifier"), "yast-hardware" ], # tree node string - CPU information "family" => [ _("Family"), "yast-hardware" ], # tree node string - CPU information "model" => [ _("Model"), "yast-hardware" ], # tree node string - CPU information "wp" => [ _("WP"), "yast-hardware" ], # tree node string - wireless network adapters "wlan" => [ _("Wireless LAN"), "yast-wifi" ], # tree node string - tape devices "tape" => [ _("Tape"), "yast-hardware" ], # tree node string - Bluetooth devices "bluetooth" => [ _("Bluetooth"), "yast-bluetooth" ], # tree node string - DSL devices "dsl" => [ _("DSL"), "yast-dsl" ], # tree node string - generic device name "Ethernet network interface" => [ _("Ethernet Network Interface"), "yast-lan" ], # tree node string - generic device name "Network Interface" => [ _("Network Interface"), "yast-lan" ], # tree node string - generic device name "Loopback network interface" => [ _("Loopback Network Interface"), "yast-lan" ], # tree node string - generic device name "Partition" => [ _("Partition"), "yast-disk" ], # tree node string - generic device name "Floppy Disk" => [ _("Floppy Disk"), "yast-floppy" ], # tree node string - generic device name "Floppy disk controller" => [ _("Floppy Disk Controller"), "yast-floppy" ], # tree node string - generic device name "PnP Unclassified device" => [ _("PnP Unclassified Device"), "yast-hardware" ], # tree node string - generic device name "Unclassified device" => [ _("Unclassified Device"), "yast-hardware" ], # tree node string - generic device name "Main Memory" => [ _("Main Memory"), "yast-hardware" ], # tree node string - generic device name "UHCI Host Controller" => [ _("UHCI Host Controller"), "yast-hardware" ], # tree node string - generic device name "EHCI Host Controller" => [ _("EHCI Host Controller"), "yast-hardware" ], # tree node string - generic device name "OHCI Host Controller" => [ _("OHCI Host Controller"), "yast-hardware" ], # translate "probe" to empty string # search starts from .probe node which doesn't # contain any hardware information "probe" => [ "", "yast-hardware" ] } ) # order table: list of lists. # first item of nested list is key name # second is term that should be used for formating the key- takes key name as first argument # if third item is true, the whole map will be passed to term as second argument @representant_order = [ "sub_device", "device", "model name", "model", "vendor", "irq", "start", "name", "xkbmodel", "server", "size", "unit", "width", "cylinders", "dev_name", "modules", "sub_class_id", "modules", "type" ] end |
- (Object) modules(val)
807 808 809 810 811 812 813 814 |
# File '../../src/include/hwinfo/routines.rb', line 807 def modules(val) val = deep_copy(val) Builtins.y2warning("calling modules with param: %1", val) outlist = Builtins.maplist(val) do |e| Ops.add("modprobe ", Builtins.mergestring(e, " ")) end deep_copy(outlist) end |
- (String) mount_device(device)
Mount specified device
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
# File '../../src/include/hwinfo/routines.rb', line 1085 def mount_device(device) tmpdir = Convert.to_string(SCR.Read(path(".target.tmpdir"))) mpoint = Ops.add(tmpdir, "/mount") # create mount point directory SCR.Execute(path(".target.mkdir"), mpoint) # mount device result = Convert.to_boolean( SCR.Execute(path(".target.mount"), [device, mpoint], "") ) result == true ? mpoint : nil end |
- (Object) remove_hex_prefix(_in)
1115 1116 1117 1118 1119 |
# File '../../src/include/hwinfo/routines.rb', line 1115 def remove_hex_prefix(_in) return _in if !has_hex_prefix(_in) Builtins.substring(_in, 2) end |
- (String) resolution(a, m)
reads values from map and creates formatted label for monitor resolution data
794 795 796 797 798 799 800 801 802 803 804 805 |
# File '../../src/include/hwinfo/routines.rb', line 794 def resolution(a, m) a = deep_copy(a) m = deep_copy(m) if Builtins.haskey(m, "height") return Builtins.sformat( "%1x%2", Ops.get(m, "width"), Ops.get(m, "height") ) end Ops.get_string(m, "width", "") end |
- (Boolean) save_hwinfo(file)
Save hwinfo output to the specified file
1040 1041 1042 1043 1044 1045 |
# File '../../src/include/hwinfo/routines.rb', line 1040 def save_hwinfo(file) return false if file == "" || file == nil command = Ops.add("/usr/sbin/hwinfo > ", file) SCR.Execute(path(".target.bash"), command) == 0 end |
- (Boolean) save_hwinfo_to_file(target_file_name)
Save hwinfo output to the specified file, progress popup is displayed. Display error message when saving failed.
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 |
# File '../../src/include/hwinfo/routines.rb', line 1052 def save_hwinfo_to_file(target_file_name) # window title filename = UI.AskForSaveFileName( target_file_name, "*", _("Save hwinfo Output to File") ) saved = false if filename != nil && Ops.greater_than(Builtins.size(filename), 0) # progress window content UI.OpenDialog(Label(_("Saving hardware information..."))) saved = save_hwinfo(filename) UI.CloseDialog if saved == false # error popup message Report.Error( Builtins.sformat( _("Saving output to the file '%1' failed."), target_file_name ) ) end end saved end |
- (Boolean) scalar(node)
evals to true if given value is scalar (not map or term or list)
888 889 890 891 892 893 894 895 896 897 |
# File '../../src/include/hwinfo/routines.rb', line 888 def scalar(node) node = deep_copy(node) if Ops.is_string?(node) || Ops.is_boolean?(node) || Ops.is_integer?(node) || Ops.is_float?(node) || Ops.is_locale?(node) || Ops.is_path?(node) return true end false end |
- (String) trans_bool(b)
translate boolean to Yes/No
875 876 877 878 879 880 881 882 |
# File '../../src/include/hwinfo/routines.rb', line 875 def trans_bool(b) b = deep_copy(b) if Ops.is_boolean?(b) # yes/no strings return b == true ? _("Yes") : _("No") end Builtins.sformat("%1", b) end |
- (String) trans_str(str)
translate string - looks to the translation table and returns value
854 855 856 857 858 859 |
# File '../../src/include/hwinfo/routines.rb', line 854 def trans_str(str) if !Builtins.haskey(@trans_table, str) Builtins.y2warning("Cannot translate string '%1'", str) end Ops.get(@trans_table, [str, 0], str) end |
- (Hash) translate_hw_entry(hw)
tries to determine hardware name by class_id and sub_class_id and substitues them in given map. returns modified map
821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
# File '../../src/include/hwinfo/routines.rb', line 821 def translate_hw_entry(hw) hw = deep_copy(hw) ret = deep_copy(hw) if Builtins.haskey(hw, "class_id") iclassid = Ops.get_integer(hw, "class_id", 255) classid = Ops.get_string(@ClassNames, [iclassid, "name"], "") ret = Builtins.add(ret, "class_id", classid) if Builtins.haskey(hw, "sub_class_id") isubclassid = Ops.get_integer(hw, "sub_class_id", 0) subclassid = Ops.get_string(@ClassNames, [iclassid, isubclassid], "") ret = Builtins.add(ret, "sub_class_id", subclassid) end end deep_copy(ret) end |
- (Boolean) umount_device(mount_point)
Unmount device
1103 1104 1105 |
# File '../../src/include/hwinfo/routines.rb', line 1103 def umount_device(mount_point) Convert.to_boolean(SCR.Execute(path(".target.umount"), mount_point)) end |