Exemple #1
0
 def fix_distort(self):
     if not (self.fit_params.get('pmodel',False) or \
         self.fit_params.get('nmodel',False)):
         popup = WarningDialog(text='Make sure you fit the trace centers first!')
         popup.open()
         return
     pdistort, ndistort = draw_trace(self.extractregion, self.xx, self.fit_params['pmodel'], \
         self.fit_params['nmodel'], fixdistort = True, fitdegree = self.fit_params['deg'])
     
     im1, im2 = [x for x in copy.deepcopy(self.theapp.extract_pairs[self.pair_index])]
     im1.load(); im2.load()
     #if self.current_flats:
     #    im1 = im_divide(im1, self.current_flats)
     #    im2 = im_divide(im2, self.current_flats)
     im1.data_array = undistort_imagearray(im1.data_array, pdistort)
     im2.data_array = undistort_imagearray(im2.data_array, ndistort)
     im_subtract(im1, im2, outputfile=self.current_impair.fitsfile)
     tmp = self.current_impair
     self.current_impair = FitsImage(self.current_impair.fitsfile)
     self.current_impair.header['EXREGX1'] = (tmp.get_header_keyword('EXREGX1'), 'extraction region coordinate X1')
     self.current_impair.header['EXREGY1'] = (tmp.get_header_keyword('EXREGY1'), 'extraction region coordinate Y1')
     self.current_impair.header['EXREGX2'] = (tmp.get_header_keyword('EXREGX2'), 'extraction region coordinate X2')
     self.current_impair.header['EXREGY2'] = (tmp.get_header_keyword('EXREGY2'), 'extraction region coordinate Y2')
     self.current_impair.update_fits(header_only = True)
     self.set_imagepair(self.pairstrings[self.pair_index])
     self.fit_params['nmodel'] = None
     self.fit_params['pmodel'] = None
Exemple #2
0
 def check_filestub(self, stub):
     placeholder = '#'
     reg = placeholder+'+'
     if len(re.findall(reg, stub)) != 1:
         popup = WarningDialog(text = "File format is not valid; must use '#' as placeholder only")
         popup.open()
         return
     self.current_obsnight = self.current_obsnight._replace(filestub=stub) 
Exemple #3
0
 def _show_warn_dialog(self, uri):
     from dialogs import WarningDialog
     d = WarningDialog(None)
     msg = (_("Playlist entry '%s' will be omitted from the archive since "
              "it is not a local file") % mesk.uri.unescape(str(uri)))
     d.set_markup(msg)
     d.run()
     d.destroy()
Exemple #4
0
    def fill_treeview_ddm(self):
        # Fill a list with supported hardware
        self.get_supported_hardware()

        # columns: checkbox, image (logo), device, driver
        columnTypes = ['bool', 'GdkPixbuf.Pixbuf', 'str']

        # Keep some info from the user
        showHw = []
        for hw in self.hardware:
            showHw.append([hw[0], hw[1], hw[2]])

        # Fill treeview
        self.tvDDMHandler.fillTreeview(contentList=showHw,
                                       columnTypesList=columnTypes,
                                       firstItemIsColName=True,
                                       fontSize=12000)

        # Show message if nothing is found or hardware is not supported
        title = _("Hardware scan")
        if self.notSupported:
            if len(self.hardware) < 2:
                self.set_buttons_state(False)
            msg = _("There are no available drivers for your hardware:")
            msg = "{}\n\n{}".format(msg, '\n'.join(self.notSupported))
            self.log.write(msg, 'fill_treeview_ddm')
            WarningDialog(title, msg)
        elif len(self.hardware) < 2:
            self.set_buttons_state(False)
            msg = _("DDM did not find any supported hardware.")
            self.log.write(msg, 'fill_treeview_ddm')
            MessageDialog(title, msg)
Exemple #5
0
 def on_radOldKernel_toggled(self, widget):
     if widget.get_active():
         message = "%s\n\n%s" % (
             _("Once removed you will not be able to boot these kernels!"),
             self.lblMaintenanceHelp.get_label().replace("\n", " "))
         WarningDialog(self.btnMaintenance.get_label(), message)
         self.fillTreeViewMaintenance()
Exemple #6
0
 def on_radDowngradable_toggled(self, widget):
     if widget.get_active():
         message = "%s\n\n%s" % (
             _("Downgrading packages may break your system!"),
             self.lblMaintenanceHelp.get_label().replace("\n", " "))
         WarningDialog(self.btnMaintenance.get_label(), message)
         self.fillTreeViewMaintenance()
Exemple #7
0
 def on_some_ftp_error(self, widget, error_text):
     for i in xrange(len(self.available_plugins_model)):
         self.available_plugins_model[i][C_UPGRADE] = False
     self.progressbar.hide()
     log.error(error_text)
     traceback.print_exc()
     WarningDialog(_('Ftp error'), error_text, self.window)
Exemple #8
0
 def on_radUnneeded_toggled(self, widget):
     if widget.get_active():
         message = "%s\n\n%s" % (
             _("You might need to run this several times."),
             self.lblMaintenanceHelp.get_label().replace("\n", " "))
         WarningDialog(self.btnMaintenance.get_label(), message)
         self.fillTreeViewMaintenance()
Exemple #9
0
    def on_btnExecute_clicked(self, widget):
        if exists(self.device["path"]):
            arguments = []
            arguments.append("-d {}".format(self.device["path"]))
            clear = self.chkFormatDevice.get_active()
            repair = self.chkRepairDevice.get_active()
            iso = self.device["new_iso"]
            iso_path = self.txtIso.get_text().strip()

            # ISO path does not exist
            if iso != iso_path:
                msg = _(
                    "Cannot add ISO from path: {}.\n"
                    "Please, remove the ISO path or browse for an existing ISO."
                )
                WarningDialog(self.btnExecute.get_label(),
                              msg.format(iso_path))
                return True

            # Check if there is enough space
            available = self.device["available"]
            if self.chkFormatDevice.get_active():
                available = self.device["size"]
            if (available) - self.device["new_iso_required"] < 0:
                msg = _(
                    "There is not enough space available on the pen drive.\n"
                    "Please, remove unneeded files before continuing.")
                WarningDialog(self.btnExecute.get_label(), msg)
                return True

            if clear:
                arguments.append("-f")
                arguments.append("-b")
            if repair:
                arguments.append("-r")
                arguments.append("-b")
                arguments.append("-g")
                # This should use the history file to get the original hash
                arguments.append("-s")
            if exists(iso):
                arguments.append("-i \"{}\"".format(iso))
                arguments.append("-s")

            cmd = "usb-creator {}".format(" ".join(arguments))
            self.log.write("Execute command: {}".format(cmd))
            self.exec_command(cmd)
Exemple #10
0
 def setColorButtonColor(self, colorbutton, hex_color):
     rgba_color = Gdk.RGBA()
     hex_color = hex_color.strip()
     if hex_color[0:1] != '#':
         hex_color = "#%s" % hex_color
     if rgba_color.parse(hex_color):
         colorbutton.set_rgba(rgba_color)
     else:
         msg = _("Could not set color: %s" % hex_color)
         WarningDialog(self.btnColors.get_label(), msg)
Exemple #11
0
 def _on_message_textview_key_press_event(self, widget, event):
     if event.get_state() & Gdk.ModifierType.MOD1_MASK and \
         event.keyval == Gdk.KEY_l:
         if not self.chat_control.contact.supports(NS_XHTML_IM):
             from dialogs import WarningDialog
             WarningDialog('Warning',
                 _('This contact does not support XHTML_IM'),
                 self.chat_control.parent_win.window)
             return True
         self.on_image_button_clicked(widget)
         return True
Exemple #12
0
 def extract_spectrum(self):
     if not (self.fit_params.get('pmodel',False) or \
         self.fit_params.get('nmodel',False)):
         popup = WarningDialog(text='Make sure you fit the trace centers first!')
         popup.open()
         return
     
     #need a calibration, too
     self.lamp = None
     if theapp.current_night.cals:
         self.lamp = theapp.current_night.cals.data_array if not self.current_flats \
             else im_divide(theapp.current_night.cals, self.current_flats).data_array
         self.lamp = self.lamp[self.region[1]:self.region[3]+1,self.region[0]:self.region[2]+1]
     im1, im2 = [x for x in copy.deepcopy(the_app.extract_pairs[self.pair_index])]
     im1.load(); im2.load()
     #if self.current_flats:
     #    im1 = im_divide(im1, self.current_flats)
     #    im2 = im_divide(im2, self.current_flats)
     im1.data_array = undistort_imagearray(im1.data_array, pdistort)
     im2.data_array = undistort_imagearray(im2.data_array, ndistort)
     self.tell = make_region(im1, im2, self.region, flat=self.current_flats, telluric=True)
     #tmp, self.tell = im_minimum(im1.data_array, im2.data_array)
     #self.tell = self.tell[self.region[1]:self.region[3]+1,self.region[0]:self.region[2]+1]
     self.pextract = extract(self.fit_params['pmodel'], self.extractregion, self.tell, 'pos', lamp = self.lamp)
     self.nextract = extract(self.fit_params['nmodel'], self.extractregion, self.tell, 'neg', lamp = self.lamp)
     
     #write uncalibrated spectra to fits files (will update after calibration)
     pstub = self.paths['out'] + re.sub('.fits','-ap%i',im1.fitsfile)
     ext = ('.fits','-sky.fits','-lamp.fits')
     h = im1.header
     for i, p_ap in enumerate(self.pextract):
         for j in range(p_ap.shape[1]):
             spec = p_ap[:,j]
             write_fits((pstub + ext[i]) % j, h, spec)
     
     nstub = self.paths['out'] + re.sub('.fits','-ap%i',im2.fitsfile)
     h = im2.header
     for i, n_ap in enumerate(self.nextract):
         for j in range(n_ap.shape[1]):
             spec = n_ap[:,j]
             write_fits((nstub + ext[i]) % j, h, spec)
Exemple #13
0
 def set_imagepair(self, val):
     if not self.theapp.current_target:
         popup = WarningDialog(text='You need to select a target (on the Observing Screen) before proceeding!')
         popup.open()
         return
     self.pair_index = self.pairstrings.index(val)
     fitsfile = self.paths['out']+re.sub(' ','',re.sub('.fits','',val))+'.fits'
     if not path.isfile(fitsfile):
         popup = WarningDialog(text='You have to select an extraction'\
             'region for this image pair \nbefore you can move on to this step.')
         popup.open()
         return
     self.current_impair = FitsImage(fitsfile)
     self.region = self.current_impair.get_header_keyword(*('EXREG' + x for x in ['X1','Y1','X2','Y2']))
     if not any(self.region):
         popup = WarningDialog(text='You have to select an extraction'\
             'region for this image pair \nbefore you can move on to this step.')
         popup.open()
         return
     self.current_impair.load()
     idata = ''.join(map(chr,self.current_impair.scaled))
     self.itexture.blit_buffer(idata, colorfmt='luminance', bufferfmt='ubyte', \
         size = self.current_impair.dimensions)
     self.trace_axis = 0 if get_tracedir(self.current_target.instrument_id) == 'vertical' else 1
     #tmp = self.current_impair.data_array[self.region[1]:self.region[3]+1,self.region[0]:self.region[2]+1]
     #self.extractregion = med_normal(tmp)
     tmp = self.theapp.extract_pairs[self.pair_index]
     if self.trace_axis:
         #self.trace_axis = 1
         reg = [self.region[x] for x in [1, 0, 3, 2]]
         self.extractregion = make_region(tmp[0], tmp[1], reg, self.current_flats)#.transpose()
     else:
         self.extractregion = make_region(tmp[0], tmp[1], self.region, self.current_flats).transpose()
     reg = self.region[:]
     reg[2] = reg[2] - reg[0]
     reg[3] = reg[3] - reg[1]
     self.iregion = self.itexture.get_region(*reg)
     dims = [[0,0],list(self.extractregion.shape)]
     dims[0][self.trace_axis] = 0.4 * self.extractregion.shape[self.trace_axis]
     dims[1][self.trace_axis] = 0.6 * self.extractregion.shape[self.trace_axis]
     self.tracepoints = robm(self.extractregion[dims[0][0]:dims[1][0]+1,\
         dims[0][1]:dims[1][1]+1], axis = self.trace_axis)
     self.tplot.points = interp_nan(list(enumerate(self.tracepoints)))
     pxs, self.tracepoints = zip(*self.tplot.points)
     self.drange = minmax(self.tracepoints)
     self.ids.the_graph.add_plot(self.tplot)
Exemple #14
0
 def wavecal(self):
     if not self.linelist:
         popup = WarningDialog(text="Please select a line list first.")
         popup.open()
         return
     calfile = self.paths['cal'] + self.speclist[self.spec_index]
     if self.ids.lampcal.state == 'down':
         calfile += '-lamp.fits'
     else:
         calfile += '-sky.fits'
     try:
         calib = ExtractedSpectrum(calfile)
     except:
         popup = WarningDialog(text="You don't have a calibration of this type...")
         popup.open()
         return
     niter = self.ids.numiter.text
     if self.linelist in self.linelists:
         #lldb = shelve.open('storage/linelists')
         #linelist_path = ird.deserialize(linelistdb[self.lineslist])
         linelist_path = linelistdb[self.linelist]
         #lldb.close()
     else:
         linelist_path = self.linelist
     self.calibration = calibrate_wavelength(calib, linelist_path, (self.wmin, self.wmax), niter)
     for i, w in self.calibration.parameters:
         self.current_spectrum.header['WAVECAL%i'%i] = (w, 'Wavelength calibration coefficient')
     self.current_spectrum.wav = self.calibration(range(len(self.current_spectrum.spec)))
     self.wmin = self.current_spectrum.wav.min()
     self.wmax = self.current_spectrum.wav.max()
     self.current_spectrum.plot.points = zip(self.current_spectrum.wav, self.current_spectrum.spec)
Exemple #15
0
 def set_spectrum(self, spec):
     self.spec_index = self.speclist.index(spec)
     try:
         tmp = ExtractedSpectrum(self.paths['out']+self.speclist[self.spec_index] + '.fits')
     except:
         popup = WarningDialog(text="You haven't extracted that spectrum yet!")
         popup.open()
         return
     if self.current_spectrum:
         self.ids.specdisplay.remove_plot(self.current_spectrum.plot)
     self.current_spectrum = tmp
     self.current_spectrum.plot = MeshLinePlot(color=[.9,1,1,1])
     if not self.current_spectrum.wav:
         self.wmin = 0
         self.wmax = len(self.current_spectrum.spec)-1
         self.current_spectrum.wav = range(self.wmax)
     else:
         self.wmin = self.current_spectrum.wav.min()
         self.wmax = self.current_spectrum.wav.max()
     self.dmin, self.dmax = minmax(self.current_spectrum.spec)
     self.current_spectrum.plot.points = zip(self.current_spectrum.wav, self.current_spectrum.spec)
     self.ids.specdisplay.add_plot(self.current_spectrum.plot)
Exemple #16
0
 def on_uninstall_plugin_button_clicked(self, widget):
     selection = self.installed_plugins_treeview.get_selection()
     model, iter = selection.get_selected()
     if iter:
         plugin = model.get_value(iter, PLUGIN)
         plugin_name = model.get_value(iter, NAME)
         is_active = model.get_value(iter, ACTIVE)
         try:
             gajim.plugin_manager.remove_plugin(plugin)
         except PluginsystemError as e:
             WarningDialog(_('Unable to properly remove the plugin'),
                           str(e), self.window)
             return
         model.remove(iter)
Exemple #17
0
    def tv_checkbox_toggled(self, obj, path, colNr, toggleValue):
        path = int(path)
        model = self.tvDDM.get_model()
        itr = model.get_iter(path)
        description = model[itr][2].lower()

        if 'pae' in description and not toggleValue and self.paeBooted:
            title = _("Remove kernel")
            msg = _(
                "You cannot remove a booted kernel.\nPlease, boot another kernel and try again."
            )
            self.log.write(msg, 'tv_checkbox_toggled')
            WarningDialog(title, msg)
            model[itr][0] = True
Exemple #18
0
 def run(self):
     self.set_locale()
     self.set_timezone()
     if has_internet_connection():
         self.queue_progress()
         shell_exec("apt-get update")
         self.applications()
         self.language_specific()
     else:
         msg = _(
             "SolydXK System Settings cannot download and install the software localization packages\n"
             "Please repeat this process when you established an internet connection."
         )
         WarningDialog(_("No internet connection", msg))
Exemple #19
0
 def set_imagepair(self, val):
     if not self.theapp.current_target:
         popup = WarningDialog(text='You need to select a target (on the Observing Screen) before proceeding!')
         popup.open()
         return
     pair_index = self.pairstrings.index(val)
     fitsfile = self.paths['out']+re.sub(' ','',re.sub('.fits','',val))+'.fits'
     if not path.isfile(fitsfile):
         im1, im2 = [x for x in copy.deepcopy(self.extract_pairs[pair_index])]
         im1.load(); im2.load()
         #if self.current_flats:
         #    tmp = im_divide(im1, self.current_flats)
         #    im1.header, im1.data_array = tmp
         #    tmp = im_divide(im2, self.current_flats)
         #    im2.header, im2.data_array = tmp
         im_subtract(im1, im2, outputfile=path.join(self.paths['out'],fitsfile))
     self.current_impair = FitsImage(path.join(self.paths['out'],fitsfile), load=True)
     self.ids.ipane.load_data(self.current_impair)
     self.imwid, self.imht = self.current_impair.dimensions
     if self.current_impair.get_header_keyword('EXREGX1'):
         for x in ['x1', 'y1', 'x2', 'y2']:
             tmp = self.current_impair.get_header_keyword('EXREG'+x.upper())
             if tmp[0] is not None:
                 self.set_coord(x, tmp[0])
Exemple #20
0
    def on_inslall_upgrade_clicked(self, widget):
        self.inslall_upgrade_button.set_property('sensitive', False)
        self.errors = ''

        def on_error(func, path, error):
            if func == os.path.islink:
                # if symlink
                os.unlink(path)
                return
            # access is denied or other
            # WarningDialog(_('Can\'t remove dir'), error[1], self.window)
            self.errors += str(error[1])

        name_list = []
        for i in range(len(self.model)):
            if self.model[i][C_UPGRADE]:
                name_list.append(self.model[i][C_NAME])
        for name in name_list:
            # remove dirs
            target_dir = os.path.join(gajim.MY_EMOTS_PATH, name)
            if os.path.isdir(target_dir):
                rmtree(target_dir, False, on_error)

            # unzip new files
            zip_file = os.path.join(self.__path__, 'emoticons_pack.zip')
            with zipfile.ZipFile(zip_file, 'r') as myzip:
                namelist = myzip.namelist()
                for n in namelist:
                    if not n.startswith(name):
                        continue
                    try:
                        icon_file = myzip.extract(n, path=gajim.MY_EMOTS_PATH)
                    except Exception as e:
                        self.errors += str(e)
        # unset all checkbattons
        for i in range(len(self.model)):
            self.model[i][C_UPGRADE] = False

        if self.errors:
            WarningDialog(_('Not fully installed'),
                          'Access is denied or other', self.window)
        else:
            # show dialog
            dialog = HigDialog(None, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, '',
                               _('All selected emoticons installed(upgraded)'))
            dialog.set_modal(False)
            dialog.set_transient_for(self.window)
            dialog.popup()
Exemple #21
0
    def installed_plugins_toggled_cb(self, cell, path):
        is_active = self.installed_plugins_model[path][ACTIVE]
        plugin = self.installed_plugins_model[path][PLUGIN]

        if is_active:
            gajim.plugin_manager.deactivate_plugin(plugin)
        else:
            try:
                gajim.plugin_manager.activate_plugin(plugin)
            except GajimPluginActivateException as e:
                WarningDialog(_('Plugin failed'),
                              str(e),
                              transient_for=self.window)
                return

        self.installed_plugins_model[path][ACTIVE] = not is_active
Exemple #22
0
 def on_hide(self, widget):
     for name in self.plugin.config_default_values:
         if name in ['presets', 'lat', 'lon']:
             continue
         widget = self.xml.get_object(name)
         self.plugin.config[name] = widget.get_text()
     lat = self.xml.get_object('lat').get_text()
     lon = self.xml.get_object('lon').get_text()
     if self.is_valid_coord(lat, lon):
         self.plugin.config['lat'] = lat
         self.plugin.config['lon'] = lon
         if self.plugin.active:
             self.plugin.activate()
     else:
         self.plugin.config['lat'] = '0.0'
         self.plugin.config['lon'] = '0.0'
         error_text = 'lat or lon field contains wrong value.'
         WarningDialog(_('Wrong coordinates'), error_text, self)
    def on_key_press(self, widget, event_keyval, event_keymod):
        # construct event instance from binding
        event = gtk.gdk.Event(gtk.gdk.KEY_PRESS)  # it's always a key-press here
        event.keyval = event_keyval
        event.state = event_keymod
        event.time = 0  # assign current time

        if event.keyval != gtk.keysyms.u:
            return
        if event.state != gtk.gdk.MOD1_MASK:  # ALT+u
            return
        is_supported = gajim.get_jid_from_account(self.chat_control.account) in jid_to_servers and \
                    gajim.connections[self.chat_control.account].connection != None
        if not is_supported:
            from dialogs import WarningDialog
            WarningDialog('Warning', _('Your server does not support http uploads'),
                transient_for=self.chat_control.parent_win.window)
            return
        self.on_file_button_clicked(widget)
Exemple #24
0
    def on_key_press(self, widget, event_keyval, event_keymod):
        # construct event instance from binding
        event = gtk.gdk.Event(
            gtk.gdk.KEY_PRESS)  # it's always a key-press here
        event.keyval = event_keyval
        event.state = event_keymod
        event.time = 0  # assign current time

        if event.keyval != gtk.keysyms.l:
            return
        if event.state != gtk.gdk.MOD1_MASK:  # ALT+l
            return
        if not self.chat_control.contact.supports(NS_XHTML_IM):
            from dialogs import WarningDialog
            WarningDialog('Warning',
                          _('This contact does not support XHTML_IM'),
                          self.chat_control.parent_win.window)
            return
        self.on_image_button_clicked(widget)
Exemple #25
0
        def _try_install(zip_filename):
            try:
                plugin = gajim.plugin_manager.install_from_zip(zip_filename)
            except PluginsystemError as er_type:
                error_text = str(er_type)
                if error_text == _('Plugin already exists'):
                    _on_plugin_exists(zip_filename)
                    return

                WarningDialog(error_text, '"%s"' % zip_filename, self.window)
                return
            if not plugin:
                show_warn_dialog()
                return
            model = self.installed_plugins_model
            iter_ = model.append(
                [plugin, plugin.name, False, plugin.activatable],
                self.get_plugin_icon(plugin))
            sel = self.installed_plugins_treeview.get_selection()
            sel.select_iter(iter_)
Exemple #26
0
 def fit_trace(self):
     if not self.fit_params or self.fit_params['shape'] not in ('Gaussian','Lorentzian'):
         popup = WarningDialog(text='Make sure you set up your fit parameters!')
         popup.open()
         return
     pos = {'pos':[x.slider.value for x in self.apertures['pos']], \
         'neg':[x.slider.value for x in self.apertures['neg']]}
     for x in self.trace_lines:
         if x in self.ids.the_graph.plots:
             self.ids.the_graph.remove_plot(x)
     if self.fit_params.get('man',False):
         popup = DefineTrace(npos=len(self.apertures['pos']), \
             nneg=len(self.apertures['neg']), imtexture = self.iregion)
         popup.bind(on_dismiss = self.manual_trace(popup.tracepoints))
         popup.open()
         return
     self.xx, self.fit_params['pmodel'], self.fit_params['nmodel'] = \
         fit_multipeak(self.tracepoints, pos = pos, wid = self.fit_params['wid'], \
         ptype = self.fit_params['shape'])
     self.trace_lines[0].points = zip(self.xx, self.fit_params['pmodel'](self.xx))
     self.trace_lines[1].points = zip(self.xx, self.fit_params['nmodel'](self.xx))
     self.ids.the_graph.add_plot(self.trace_lines[0])
     self.ids.the_graph.add_plot(self.trace_lines[1])
Exemple #27
0
# Handle arguments
parser = argparse.ArgumentParser(description="DDM")
parser.add_argument('-t', action="store_true", help='Testing only: install drivers for pre-defined hardware')
parser.add_argument('-f', action="store_true", help='Force DDM to start even in a live environment')
args, extra = parser.parse_known_args()
test = args.t
force = args.f


# Warn for the use of proprietary drivers
title = _("Device Driver Manager")
msg = _("Device Driver Manager helps to install proprietary drivers for your hardware.\n"
        "Only install proprietary drivers if you are sure you really need them.\n"
        "Usually open drivers are enough.")
WarningDialog(title, msg, None, None, True, 'ddm')


# Set variables
scriptDir = os.path.dirname(os.path.realpath(__file__))


def isRunningLive():
    if force:
        return False
    liveDirs = ['/live', '/lib/live/mount', '/rofs']
    for ld in liveDirs:
        if os.path.exists(ld):
            return True
    return False
Exemple #28
0
if args.reload:
    arguments.append("-r")
if args.clear_upd:
    clearUpHistory()
if args.quick:
    arguments.append("-q")

# Finish arguments string
arguments.append("&")

msg = _("Update Manager cannot be started in a live environment\n"
        "You can use the --force argument to start UM in a live environment")

if args.pref:
    if isRunningLive() and not args.force:
        WarningDialog(umglobal.title, msg, None, None, True, 'update-manager')
    else:
        if umglobal.isProcessRunning("updatemanagerpref.py"):
            print(("updatemanagerpref.py already running - exiting"))
        else:
            cmd = "python3 {0}/updatemanagerpref.py {1}".format(
                scriptDir, " ".join(arguments))
            if launcher != "":
                cmd = "{0} '{1}'".format(launcher, cmd)
            print(cmd)
            os.system(cmd)
else:
    if not isRunningLive() and not args.force:
        if umglobal.isProcessRunning("updatemanagertray.py"):
            print(("updatemanagertray.py already running - exiting"))
        else:
Exemple #29
0
    def on_btnSave_clicked(self, widget):
        # Save selected hardware
        arguments = []

        model = self.tvDDM.get_model()
        itr = model.get_iter_first()
        while itr is not None:
            action = 'no change'
            selected = model.get_value(itr, 0)
            device = model.get_value(itr, 2)
            manufacturerId = ''

            # Check currently selected state with initial state
            # This decides whether we should install or purge the drivers
            for hw in self.hardware:
                self.log.write("Device = {} in {}".format(device, hw[2]),
                               'on_btnSave_clicked')
                if device in hw[2]:
                    manufacturerId = hw[4]
                    if hw[0] and not selected:
                        action = 'purge'
                    elif not hw[0] and selected:
                        action = 'install'
                    break

            self.log.write(
                "{}: {} ({})".format(action, device, manufacturerId),
                'on_btnSave_clicked')

            # Install/purge selected driver
            option = ""
            if action == 'install':
                option = "-i"
            elif action == 'purge':
                option = "-p"

            if option:
                driver = ''
                # Run the manufacturer specific bash script
                if manufacturerId == '1002':
                    driver = 'ati'
                elif manufacturerId == '10de':
                    driver = 'nvidia '
                elif manufacturerId == '14e4':
                    driver = 'broadcom '
                elif 'pae' in manufacturerId:
                    driver = 'pae '
                if driver:
                    arguments.append("{} {}".format(option, driver))

            # Get the next in line
            itr = model.iter_next(itr)

        # Execute the command
        if arguments:
            if '-i' in arguments and not hasInternetConnection():
                title = _("No internet connection")
                msg = _(
                    "You need an internet connection to install the additional software.\n"
                    "Please, connect to the internet and try again.")
                WarningDialog(title, msg)
            else:
                # Warn for use of Backports
                if self.chkBackports.get_active():
                    answer = QuestionDialog(
                        self.chkBackports.get_label(),
                        _("You have selected to install drivers from the backports repository whenever they are available.\n\n"
                          "Although you can run more up to date software using the backports repository,\n"
                          "you introduce a greater risk of breakage doing so.\n\n"
                          "Are you sure you want to continue?"))
                    if not answer:
                        self.chkBackports.set_active(False)
                        return True
                    arguments.append("-b")

                # Testing
                if self.test:
                    arguments.append("-t")

                command = "ddm {}".format(" ".join(arguments))
                self.log.write("Command to execute: {}".format(command),
                               'on_btnSave_clicked')
                self.exec_command(command)
Exemple #30
0
    def get_ati(self):
        # Debian Wiki: https://wiki.debian.org/ATIProprietary
        # Supported devices 14.9 (Jessie): http://support.amd.com/en-us/kb-articles/Pages/AMDCatalyst14-9LINReleaseNotes.aspx

        manufacturerId = '1002'
        startSeries = 5000
        deviceArray = self.get_lspci_info(manufacturerId, 'VGA')

        if self.test:
            #deviceArray = [['Advanced Micro Devices [AMD] nee ATI Manhattan [Mobility Radeon HD 5400 Series]', manufacturerId, '68e0']]
            #deviceArray = [['Advanced Micro Devices, Inc. [AMD/ATI] RV710 [Radeon HD 4350/4550]', manufacturerId, '68e0']]
            #deviceArray = [['Advanced Micro Devices [AMD/ATI] RS880 [Radeon HD 4290]', manufacturerId, '68e0']]
            #deviceArray = [['Advanced Micro Devices, Inc. [AMD/ATI] Tonga PRO [Radeon R9 285]', manufacturerId, '6939']]
            deviceArray = [[
                'Advanced Micro Devices, Inc. [AMD/ATI] Bonaire [FirePro W5100]',
                manufacturerId, '6649'
            ]]

        if deviceArray:
            self.log.write("Device(s): {}".format(deviceArray), 'get_ati')
            # Check if fglrx is loaded
            # If it is: checkbox is selected
            loadedDrv = self.get_loaded_graphical_driver()
            self.log.write("Loaded graphical driver: {}".format(loadedDrv),
                           'get_ati')

            # Get the manufacturer's logo
            logo = join(self.mediaDir, 'images/ati.png')

            # Fill the hardware array
            for device in deviceArray:
                self.log.write("ATI device found: {}".format(device[0]),
                               'get_ati')
                # Check for supported cards
                matchObj = re.search(
                    'radeon\s+[0-9a-z ]+|fire[a-z]+\s+[0-9a-z -]+',
                    device[0],
                    flags=re.IGNORECASE)
                if matchObj:
                    if " hd " in matchObj.group(0).lower():
                        # Check if ATI series is above 5000
                        matchObjSeries = re.search('[0-9]{4}',
                                                   matchObj.group(0))
                        if matchObjSeries:
                            series = int(matchObjSeries.group(0))
                            # Don't show older ATI Radeon HD cards
                            if series < startSeries:
                                break
                    elif 'fire' in matchObj.group(0).lower():
                        title = _("ATI FirePro/Gl card found")
                        msg = _(
                            "Installing the proprietary driver for an ATI FirePro/Gl card may render your system unbootable.\n\n"
                            "Proceed at your own risk.")
                        self.log.write(msg, 'get_ati')
                        WarningDialog(title, msg)

                    self.log.write("ATI series: {}".format(matchObj.group(0)),
                                   'get_ati')

                    # Check if the available driver is already loaded
                    selected = False
                    driver = 'fglrx'
                    if loadedDrv == driver:
                        selected = True

                    # Fill self.hardware
                    #shortDevice = self.shorten_long_string(device[0], 100)
                    self.hardware.append([
                        selected, logo, device[0], driver, device[1], device[2]
                    ])
                else:
                    self.notSupported.append(device[0])
Exemple #31
0
 def show_warn_dialog():
     text = _('Archive is malformed')
     dialog = WarningDialog(text, '', transient_for=self.window)
     dialog.set_modal(False)
     dialog.popup()
Exemple #32
0
Fichier : gui.py Projet : irl/gajim
 def show_warn_dialog():
     text = _('Archive is malformed')
     dialog = WarningDialog(text, '', transient_for=self.window)
     dialog.set_modal(False)
     dialog.popup()