Ejemplo n.º 1
0
def process():
    global NvLtDrvURL, LatestFile, LatestHeader, DownloadFlag, SymlinkFlag
    screen = SnackScreen()
    bb = ButtonBar(screen, (("End", "end"), ))
    tbTittle = Textbox(65, 3, "Processing Input... ", 0, 1)

    tbDownload = Textbox(65, 3, " ", 0, 1)

    tbSymlink = Textbox(65, 3, " ", 0, 1)

    g = GridForm(screen, "chkltdr (NvDrIn) - by Trodskovich", 1, 6)
    g.add(tbTittle, 0, 2)
    g.add(tbDownload, 0, 3, growx=1)
    g.add(tbSymlink, 0, 4, growx=1)
    g.add(bb, 0, 5, growx=1)

    if DownloadFlag:
        tbDownload.setText("Downloading Please Wait...")
        result = g.runOnce()
        screen.finish()
        urllib.request.urlretrieve(NvLtDrvURL, "./" + LatestFile)
    else:
        tbDownload.setText("Download Skipped")

    if SymlinkFlag:
        subprocess.call(
            ["ln -nfs ./" + LatestFile + " NVIDIA-Linux-x86_64-Latest.run"],
            shell=True)
        tbSymlink.setText("Symlink Created")
    else:
        tbSymlink.setText("Symlink Skipped")
    result = g.runOnce()
    screen.finish()
    return bb.buttonPressed(result)
Ejemplo n.º 2
0
 def __init__(self, screen, title, text):
     self.screen = screen
     self.g = GridForm(self.screen, title, 1, 2)
     self.s = Scale(70, 100)
     self.t = Textbox(70, 12, text)
     self.g.add(self.s, 0, 0)
     self.g.add(self.t, 0, 1, padding=(0, 1, 0, 0))
Ejemplo n.º 3
0
 def display(self):
     button_save, button_exit = Button("Update"), Button("Back")
     separator = (Textbox(20, 1, "", 0, 0), Textbox(20, 1, "", 0, 0))
     rows = [(Textbox(20, 1, "Memory size (GB):", 0,
                      0), self.memory), separator,
             (Textbox(20, 1, "Swap size (GB):", 0,
                      0), self.swap), separator,
             (Textbox(20, 1, "Nr. of CPUs:", 0, 0), self.vcpu), separator,
             (Textbox(20, 1, "CPU usage limit (%):", 0, 0), self.vcpulimit),
             separator, (Textbox(20, 1, "Disk size (GB):", 0,
                                 0), self.disk), separator,
             (Textbox(20, 1, "IO Priority:", 0, 0), self.ioprio), separator,
             (Textbox(20, 1, "Bind mounts:", 0, 0), self.bind_mounts),
             (Textbox(20, 1, "", 0,
                      0), Textbox(20, 1, "/src1,/dst1;/srcN,..", 0,
                                  0)), separator,
             (Textbox(20, 1, "Hostname:", 0, 0), self.hostname), separator,
             (Textbox(20, 1, "", 0, 0), self.onboot), separator,
             (Textbox(20, 1, "Boot order:", 0,
                      0), self.bootorder), separator,
             (Textbox(20, 1, "VEID:", 0, 0), self.ctid), separator,
             (button_exit, button_save)]
     form = GridForm(self.screen, self.title, 2, len(rows))
     for i, row in enumerate(rows):
         for j, cell in enumerate(row):
             form.add(cell, j, i)
     return form.runOnce() != button_exit
Ejemplo n.º 4
0
 def display(self):
     button_save, button_exit = Button("Edit"), Button("Cancel")
     rows = self._define_view(button_save, button_exit)
     form = GridForm(self.screen, self.title, 2, len(rows))
     for i, row in enumerate(rows):
         for j, cell in enumerate(row):
             form.add(cell, j, i)
     return form.runOnce() != button_exit
Ejemplo n.º 5
0
 def display(self):
     button_save, button_exit = Button("Migrate"), Button("Back")
     separator = (Textbox(20, 1, "", 0, 0), Textbox(20, 1, "", 0, 0))
     rows = [(Textbox(20, 1, "Hostname/IP:", 0, 0), self.target), separator,
             (Textbox(20, 1, "Live migration:", 0, 0), self.live),
             separator, (button_save, button_exit)]
     form = GridForm(self.screen, self.title, 2, len(rows))
     for i, row in enumerate(rows):
         for j, cell in enumerate(row):
             form.add(cell, j, i)
     return form.runOnce() != button_exit
Ejemplo n.º 6
0
    def __init__(self, screen, title, text):
        self.screen = screen
        width = 40
        if (len(text) < width):
            width = len(text)

        t = TextboxReflowed(width, text)

        g = GridForm(self.screen, title, 1, 1)
        g.add(t, 0, 0)
        g.draw()
        self.screen.refresh()
Ejemplo n.º 7
0
def select_packages():
    global sellist
    screen = SnackScreen()
    ct = CheckboxTree(height=20, scroll=1)

    for idx, key in enumerate(packages):
        ct.append(key)
        for val in packages[key]:
            ct.addItem(val, (idx, snackArgs["append"]))
            ct.setEntryValue(val)

    bb = ButtonBar(screen, (("Next", "next"), ("Cancel", "cancel")))
    g = GridForm(screen, "Packages", 1, 4)

    g.add(ct, 0, 2)
    g.add(bb, 0, 3, growx=1)

    result = g.runOnce()
    screen.finish()

    # format selected packages list for zypper  and print(result)
    sellist = (str(ct.getSelection()).replace("[",
                                              "").replace("]", "").replace(
                                                  "'", "").replace(",", ""))
    # to confirm Selected Packages
    screen = SnackScreen()
    bb = ButtonBar(screen, (("Next", "next"), ("Cancel", "cancel")))
    tb = Textbox(
        80, 10,
        "the packages selected to install are \n \n" + str(sellist.split(" ")),
        1, 1)
    g = GridForm(screen, "Selected Packages", 1, 4)

    g.add(tb, 0, 2)
    g.add(bb, 0, 3, growx=1)

    result = g.runOnce()
    screen.finish()
    return bb.buttonPressed(result)
Ejemplo n.º 8
0
def welcome():
    screen = SnackScreen()
    bb = ButtonBar(screen, (("Continue", "continue"), ("Cancel", "cancel")))
    tb = Textbox(
        65,
        4,
        "Python Script to Initialize New openSUSE Tumbleweed Installation,\nlike Installing Applications, Enabling & Starting Services, \nand Performing Distrubution Update.",
    )
    g = GridForm(screen, "TW-Init - by Trodskovich", 1, 4)

    g.add(tb, 0, 2)
    g.add(bb, 0, 3, growx=1)

    result = g.runOnce()
    screen.finish()
    return bb.buttonPressed(result)
Ejemplo n.º 9
0
def dup():
    screen = SnackScreen()
    bb = ButtonBar(screen, (("Yes", "yes"), ("No", "no")))
    tb = Textbox(
        70,
        4,
        "It's recomended to run the Distribution Update after Initiliazation. \nDo you want to run Distribution Update after Initiliazation ?",
    )
    g = GridForm(screen, "Distribution Update", 1, 4)

    g.add(tb, 0, 2)
    g.add(bb, 0, 3, growx=1)

    result = g.runOnce()
    screen.finish()
    return bb.buttonPressed(result)
Ejemplo n.º 10
0
 def create_ui(self):
     """ Creates/Draws the UI """
     self.button_bar = ButtonBar(self.screen, ((_("Cancel"), "cancel"),
                                               (_("Install"), "ok")),
                                 compact=True)
     self.textview_changes = Textbox(72, 8, "Changelog", True, True)
     self.checkbox_tree_updates = CheckboxTree(height=8, width=72, scroll=1)
     self.checkbox_tree_updates.setCallback(self.checkbox_changed)
     self.layout = GridForm(self.screen, "Updates", 1, 5)
     self.layout.add(self.checkbox_tree_updates, 0, 0)
     # empty line to make it look less crowded
     self.layout.add(Textbox(60, 1, " ", False, False), 0, 1)
     self.layout.add(self.textview_changes, 0, 2)
     # empty line to make it look less crowded
     self.layout.add(Textbox(60, 1, " ", False, False), 0, 3)
     self.layout.add(self.button_bar, 0, 4)
     # FIXME: better progress than the current suspend/resume screen thing
     self.screen.suspend()
Ejemplo n.º 11
0
def add_repo():
    screen = SnackScreen()
    bb = ButtonBar(screen, (("Add", "add"), ("Cancel", "cancel")))
    tb = Textbox(
        50,
        5,
        "Multimedia Applications and Codecs require Packman Repositary to be added in order to work correctly. \nDo you want add Packman repo now ?",
        0,
        1,
    )
    g = GridForm(screen, "Packman Repo", 1, 4)

    g.add(tb, 0, 2)
    g.add(bb, 0, 3, growx=1)

    result = g.runOnce()
    screen.finish()
    return bb.buttonPressed(result)
Ejemplo n.º 12
0
 def display(self):
     button_exit, button_save = Button("Back"), Button("Create VM")
     separator = (Textbox(20, 1, "", 0, 0), Textbox(20, 1, "", 0, 0))
     rows = [
         (Textbox(20, 1, "Memory size (GB):", 0, 0), self.memory),
         (Textbox(20, 1, "Memory min/max:", 0, 0),
          Textbox(
              20, 1,
              "%s / %s" % (self.memory.min_value, self.memory.max_value), 0,
              0)), (Textbox(20, 1, "VSwap size (GB):", 0, 0), self.swap),
         (Textbox(20, 1, "VSwap min/max:", 0, 0),
          Textbox(20, 1,
                  "%s / %s" % (self.swap.min_value, self.swap.max_value), 0,
                  0)), (Textbox(20, 1, "Number of CPUs:", 0, 0), self.vcpu),
         (Textbox(20, 1, "CPU number min/max:", 0, 0),
          Textbox(20, 1,
                  "%s / %s" % (self.vcpu.min_value, self.vcpu.max_value), 0,
                  0)),
         (Textbox(20, 1, "CPU usage limit (%):", 0, 0), self.vcpulimit),
         (Textbox(20, 1, "CPU usage min/max:", 0, 0),
          Textbox(
              20, 1, "%s / %s" %
              (self.vcpulimit.min_value, self.vcpulimit.max_value), 0, 0)),
         (Textbox(20, 1, "Disk size (GB):", 0, 0), self.disk),
         (Textbox(20, 1, "Disk size min/max:", 0, 0),
          Textbox(20, 1,
                  "%s / %s" % (self.disk.min_value, self.disk.max_value), 0,
                  0)), (Textbox(20, 1, "IO Priority:", 0, 0), self.ioprio),
         (Textbox(20, 1, "Bind mounts:", 0, 0), self.bind_mounts),
         (Textbox(20, 1, "", 0,
                  0), Textbox(20, 1, "/src1,/dst1;/srcN,..", 0, 0)),
         (Textbox(20, 1, "Hostname:", 0, 0), self.hostname),
         (Textbox(20, 1, "IP-address:", 0, 0), self.ip_address),
         (Textbox(20, 2, "Nameserver:", 0, 0), self.nameserver),
         (Textbox(20, 1, "Root password:"******"Root password x2:", 0, 0), self.password2),
         (Textbox(20, 2, "OS Template:", 0, 0), self.ostemplate),
         (self.startvm, self.onboot), separator, (button_save, button_exit)
     ]
     form = GridForm(self.screen, self.title, 2, len(rows))
     for i, row in enumerate(rows):
         for j, cell in enumerate(row):
             form.add(cell, j, i)
     return form.runOnce() != button_exit
Ejemplo n.º 13
0
    def __init__(self, screen, title, text, total, updpct=0.05, pulse=False):
        self.multiplier = 1
        if total == 1.0:
            self.multiplier = 100
        self.screen = screen
        width = 55
        if (len(text) > width):
            width = len(text)

        t = TextboxReflowed(width, text)

        g = GridForm(self.screen, title, 1, 2)
        g.add(t, 0, 0, (0, 0, 0, 1), anchorLeft=1)

        self.scale = Scale(int(width), int(float(total) * self.multiplier))
        if not pulse:
            g.add(self.scale, 0, 1)

        g.draw()
        self.screen.refresh()
Ejemplo n.º 14
0
    def run(self):
        toplevel = GridForm(self.screen, _("Passphrase"), 1, 3)

        txt = TextboxReflowed(65, self.txt)
        toplevel.add(txt, 0, 0)

        passphraseentry = Entry(60, password=1)
        toplevel.add(passphraseentry, 0, 1, (0, 0, 0, 1))

        buttons = ButtonBar(self.screen, [TEXT_OK_BUTTON, TEXT_CANCEL_BUTTON])
        toplevel.add(buttons, 0, 2, growx=1)

        rc = toplevel.run()
        res = buttons.buttonPressed(rc)

        passphrase = None
        if res == TEXT_OK_CHECK or rc == "F12":
            passphrase = passphraseentry.value().strip()

        self.rc = passphrase
        return self.rc
Ejemplo n.º 15
0
def ExtCheckboxWindow(screen, title, text, items,
                      buttons=('Ok', 'Cancel'), width=50, height=8):

    g = GridForm(screen, title, 1, 3)
    g.add(Textbox(width, 2, text), 0, 0)

    scroll = 0
    if len(items) > height:
        scroll = 1

    ct = CheckboxTree(height, scroll, width)
    if len(items) > 0:
        for i in items:
            ct.append(i, i, items[i])
        g.add(ct, 0, 1)

    bb = ButtonBar(screen, buttons, compact=1)
    g.add(bb, 0, 2, (0, 2, 0, 0), growx=1, growy=1)

    result = g.runOnce()
    return bb.buttonPressed(result), ct.getSelection()
Ejemplo n.º 16
0
 def display(self):
     button_save, button_exit = Button("Create"), Button("Back")
     separator = (Textbox(20, 1, "", 0, 0), Textbox(20, 1, "", 0, 0))
     rows = [(Textbox(20, 1, "Memory size (GB):", 0, 0), self.memory),
             (Textbox(20, 1, "Min memory size (GB):", 0,
                      0), self.memory_min),
             (Textbox(20, 1, "Max memory size (GB):", 0,
                      0), self.memory_max), separator,
             (Textbox(20, 1, "Number of CPUs:", 0, 0), self.vcpu),
             (Textbox(20, 1, "Min number of CPUs:", 0, 0), self.vcpu_min),
             (Textbox(20, 1, "Max number of CPUs:", 0,
                      0), self.vcpu_max), separator,
             (Textbox(20, 1, "Disk size (GB):", 0,
                      0), self.disk), separator,
             (Textbox(20, 1, "OS template:", 0, 0), self.ostemplate),
             separator, (button_exit, button_save)]
     form = GridForm(self.screen, self.title, 2, len(rows))
     for i, row in enumerate(rows):
         for j, cell in enumerate(row):
             form.add(cell, j, i)
     return form.runOnce() != button_exit
    def __init__(self, datadir):
        self.screen = SnackScreen()
        # FIXME: self.screen.finish() clears the screen (and all messages)
        #        there too
        #atexit.register(self.restoreScreen)
        self.button_bar = ButtonBar(self.screen, ((_("Cancel"), "cancel"),
                                                  (_("Install"), "ok")),
                                    compact=True)
        self.textview_changes = Textbox(72, 8, _("Changelog"), True, True)
        self.checkbox_tree_updates = CheckboxTree(height=8, width=72, scroll=1)
        self.checkbox_tree_updates.setCallback(self.checkbox_changed)
        self.layout = GridForm(self.screen, _("Updates"), 1, 5)
        self.layout.add(self.checkbox_tree_updates, 0, 0)
        # empty line to make it look less crowded
        self.layout.add(Textbox(60, 1, " ", False, False), 0, 1)
        self.layout.add(self.textview_changes, 0, 2)
        # empty line to make it look less crowded
        self.layout.add(Textbox(60, 1, " ", False, False), 0, 3)
        self.layout.add(self.button_bar, 0, 4)
        # FIXME: better progress than the current suspend/resume screen thing
        self.screen.suspend()
        if not self.DEBUG:
            apt_pkg.pkgsystem_lock()
        self.openCache()
        print(_("Building Updates List"))
        self.fillstore()
        if self.list.distUpgradeWouldDelete > 0:
            print(
                _("""
A normal upgrade can not be calculated, please run:
  sudo apt-get dist-upgrade


This can be caused by:
 * A previous upgrade which didn't complete
 * Problems with some of the installed software
 * Unofficial software packages not provided by Ubuntu
 * Normal changes of a pre-release version of Ubuntu"""))
            sys.exit(1)
        self.screen.resume()
Ejemplo n.º 18
0
    def display(self):
        button_save, button_exit = Button("Create VM"), Button("Main menu")
        separator = (Textbox(20, 1, "", 0, 0), Textbox(20, 1, "", 0, 0))
        rows = [
            (Textbox(20, 1, "Memory size (GB):", 0, 0), self.memory),
            (Textbox(20, 1, "Memory min/max:", 0, 0),
             Textbox(
                 20, 1,
                 "%s / %s" % (self.memory.min_value, self.memory.max_value), 0,
                 0)), separator,
            (Textbox(20, 1, "Number of CPUs:", 0, 0), self.vcpu),
            (Textbox(20, 1, "CPU number min/max:", 0, 0),
             Textbox(20, 1,
                     "%s / %s" % (self.vcpu.min_value, self.vcpu.max_value), 0,
                     0)), separator,
            (Textbox(20, 1, "Hostname:", 0, 0), self.hostname), separator,
            (button_save, button_exit)
        ]

        form = GridForm(self.screen, self.title, 2, len(rows))
        for i, row in enumerate(rows):
            for j, cell in enumerate(row):
                form.add(cell, j, i)
        return form.runOnce() != button_exit
Ejemplo n.º 19
0
 def __init__(self, screen, title, text):
     self.screen = screen
     self.g = GridForm(screen, title, 1, 1)
     self.g.add(Textbox(60, 2, text), 0, 0)
Ejemplo n.º 20
0
def welcome():
    global NvLtDrvURL, LatestFile, LatestHeader, DownloadFlag, SymlinkFlag
    screen = SnackScreen()
    bb = ButtonBar(screen, (("Continue", "continue"), ("Cancel", "cancel")))
    tbTittle = Textbox(
        65, 3,
        "To check for latest Nvidia Driver form NVIDIA Website, download and optionaly create a symlink to the latest File",
        0, 1)
    for File in os.listdir(path):
        if File.find('.run') > 0 and os.path.isfile(path + "/" + File):
            FList.append(File)
            FList.sort()
    FileText = urllib.request.urlopen(NvLtTxtURL).read().decode('utf-8')
    for i in range(0, len(FileText)):
        if FileText[i] == ' ':
            LatestHeader = FileText[0:i]

    for i in range(0, len(FileText)):
        if FileText[i] == '/':
            LatestFile = FileText[i + 1:len(FileText) - 1]

    NvLtDrvURL = NvLtDrvURL + LatestHeader + "/" + LatestFile

    tbLatestL = Textbox(110, 2, "Latest Local Version: " + FList[-1], 0, 1)
    tbLatestR = Textbox(
        110, 4, "Latest Remote Version: " + LatestFile +
        "\nLatest Driver URL: " + NvLtDrvURL, 0, 1)

    if LatestFile > FList[-1]:
        cbDowload = Checkbox(
            "Download the Latest Driver",
            1,
        )
        cbSymlink = Checkbox(
            "Create / Update Symlink",
            1,
        )
    else:
        cbDowload = Checkbox(
            "Download the Latest Driver",
            0,
        )
        cbSymlink = Checkbox(
            "Create / Update Symlink",
            0,
        )

    g = GridForm(screen, "chkltdr (NvDrIn) - by Trodskovich", 1, 8)

    g.add(tbTittle, 0, 2)
    g.add(tbLatestL, 0, 3, growx=1)
    g.add(tbLatestR, 0, 4, growx=1)
    g.add(cbDowload, 0, 5, growx=1)
    g.add(cbSymlink, 0, 6, growx=1)
    g.add(bb, 0, 7, growx=1)
    result = g.runOnce()

    screen.finish()
    DownloadFlag = cbDowload.value()
    SymlinkFlag = cbSymlink.value()
    return bb.buttonPressed(result)