Esempio n. 1
0
    def __init__(self, proyecto_path):

        Gtk.EventBox.__init__(self)

        archivo = os.path.join(proyecto_path, "proyecto.ide")
        arch = open(archivo, "r")
        self.proyecto = json.load(arch, "utf-8")
        arch.close()

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.install_path = os.path.join(CONFPATH, self.proyecto["nombre"])
        self.widgeticon = WidgetIcon("python", self.install_path)
        self.notebook = Notebook(proyecto_path)
        self.terminal = Terminal()

        label = Gtk.Label(u"Instalador python para: %s versión: %s" % (
            self.proyecto["nombre"], self.proyecto["version"]))
        label.modify_font(Pango.FontDescription("%s %s" % ("Monospace", 12)))
        label.modify_fg(0, Gdk.Color(0, 0, 65000))

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        image = Gtk.Image()
        arch = os.path.join(BASEPATH, "Iconos", "gandalftux.png")
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(arch, 100, 100)
        image.set_from_pixbuf(pixbuf)
        hbox.pack_start(image, False, False, 0)
        vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox2.pack_start(label, False, False, 0)
        vbox2.pack_start(self.widgeticon, False, False, 0)
        hbox.pack_start(vbox2, True, True, 0)
        vbox.pack_start(hbox, False, False, 0)

        vbox.pack_start(self.notebook, True, True, 0)
        vbox.pack_start(self.terminal, True, True, 5)

        self.add(vbox)
        self.connect("realize", self.__realize)
        self.show_all()

        self.widgeticon.connect("iconpath", self.__set_iconpath)
        self.widgeticon.connect("make", self.__make)
Esempio n. 2
0
class SugarWidget(Gtk.EventBox):

    __gtype_name__ = 'JAMediaEditorSugarWidget'

    def __init__(self, proyecto_path):

        Gtk.EventBox.__init__(self)

        archivo = os.path.join(proyecto_path, "proyecto.ide")
        arch = open(archivo, "r")
        self.proyecto = json.load(arch, "utf-8")
        arch.close()

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.notebook = Notebook(proyecto_path)
        self.install_path = os.path.join(CONFPATH,
            "%s.activity" % self.proyecto["nombre"])
        self.widgeticon = WidgetIcon("sugar", self.install_path)

        label = Gtk.Label(u"Instalador Sugar para: %s versión: %s" % (
            self.proyecto["nombre"], self.proyecto["version"]))
        label.modify_font(Pango.FontDescription("%s %s" % ("Monospace", 12)))
        label.modify_fg(0, Gdk.Color(0, 0, 65000))

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        image = Gtk.Image()
        arch = os.path.join(BASEPATH, "Iconos", "gandalftux.png")
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(arch, 100, 100)
        image.set_from_pixbuf(pixbuf)
        hbox.pack_start(image, False, False, 0)
        vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox2.pack_start(label, False, False, 0)
        vbox2.pack_start(self.widgeticon, False, False, 0)
        hbox.pack_start(vbox2, True, True, 0)
        vbox.pack_start(hbox, False, False, 0)

        vbox.pack_start(self.notebook, True, True, 0)

        self.add(vbox)
        self.show_all()

        self.widgeticon.connect("iconpath", self.__set_iconpath)
        self.widgeticon.connect("make", self.__make)

    def __make(self, widget):
        t = "Construyendo el Instalador."
        t = "%s\n%s" % (t, "Por favor espera un momento . . .")
        dialogo = DialogoLoad(self.get_toplevel(), t)
        dialogo.connect("running", self.__run_make)
        dialogo.run()

    def __run_make(self, dialogo):
        self.notebook.guardar()
        # Limpiar y establecer permisos de archivos y directorios
        get_installers_data(self.install_path)

        zippath = "%s.xo" % (self.install_path)
        # Borrar anterior
        if os.path.exists(zippath):
            os.remove(zippath)
        zipped = zipfile.ZipFile(zippath, "w")

        for (archiveDirPath, dirNames, fileNames) in os.walk(self.install_path):
            for fileName in fileNames:
                filePath = os.path.join(archiveDirPath, fileName)
                zipped.write(filePath, filePath.split(self.install_path)[1])
        zipped.close()
        os.chmod(zippath, 0755)

        dialogo.destroy()
        t = "Proceso Concluido."
        t = "%s\n%s" % (t, "El instalador se encuentra en")
        t = "%s: %s" % (t, CONFPATH)
        # FIXME: Pedir para borrar directorio temporal ?
        dialogo = DialogoInformar(self.get_toplevel(), t)
        dialogo.run()
        dialogo.destroy()

    def __set_iconpath(self, widget, iconpath):
        path = os.path.join(self.install_path, "activity",
            os.path.basename(iconpath))
        if iconpath != path:
            shutil.copyfile(iconpath, path)
        self.notebook.set_icon(path)
Esempio n. 3
0
class PythonWidget(Gtk.EventBox):

    __gtype_name__ = 'JAMediaEditorPythonWidget'

    def __init__(self, proyecto_path):

        Gtk.EventBox.__init__(self)

        archivo = os.path.join(proyecto_path, "proyecto.ide")
        arch = open(archivo, "r")
        self.proyecto = json.load(arch, "utf-8")
        arch.close()

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.install_path = os.path.join(CONFPATH, self.proyecto["nombre"])
        self.widgeticon = WidgetIcon("python", self.install_path)
        self.notebook = Notebook(proyecto_path)
        self.terminal = Terminal()

        label = Gtk.Label(u"Instalador python para: %s versión: %s" % (
            self.proyecto["nombre"], self.proyecto["version"]))
        label.modify_font(Pango.FontDescription("%s %s" % ("Monospace", 12)))
        label.modify_fg(0, Gdk.Color(0, 0, 65000))

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        image = Gtk.Image()
        arch = os.path.join(BASEPATH, "Iconos", "gandalftux.png")
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(arch, 100, 100)
        image.set_from_pixbuf(pixbuf)
        hbox.pack_start(image, False, False, 0)
        vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox2.pack_start(label, False, False, 0)
        vbox2.pack_start(self.widgeticon, False, False, 0)
        hbox.pack_start(vbox2, True, True, 0)
        vbox.pack_start(hbox, False, False, 0)

        vbox.pack_start(self.notebook, True, True, 0)
        vbox.pack_start(self.terminal, True, True, 5)

        self.add(vbox)
        self.connect("realize", self.__realize)
        self.show_all()

        self.widgeticon.connect("iconpath", self.__set_iconpath)
        self.widgeticon.connect("make", self.__make)

    def __realize(self, widget):
        self.terminal.hide()

    def __make(self, widget):
        t = "Construyendo el Instalador."
        t = "%s\n%s" % (t, "Por favor espera un momento . . .")
        dialogo = DialogoLoad(self.get_toplevel(), t)
        dialogo.connect("running", self.__run_make)
        dialogo.run()

    def __run_make(self, dialogo):
        self.terminal.reset()
        self.notebook.guardar()
        desktop = os.path.join(self.install_path,
            "%s.desktop" % self.proyecto["nombre"])
        lanzador = os.path.join(self.install_path,
            self.proyecto["nombre"].lower())
        setup = os.path.join(self.install_path, "setup.py")
        for path in [setup, desktop, lanzador]:
            os.chmod(path, 0755)

        python_path = "/usr/bin/python"
        if os.path.exists(os.path.join("/bin", "python")):
            python_path = os.path.join("/bin", "python")
        elif os.path.exists(os.path.join("/usr/bin", "python")):
            python_path = os.path.join("/usr/bin", "python")
        elif os.path.exists(os.path.join("/sbin", "python")):
            python_path = os.path.join("/sbin", "python")
        elif os.path.exists(os.path.join("/usr/local", "python")):
            python_path = os.path.join("/usr/local", "python")

        self.terminal.show_all()
        self.terminal.connect("reset", self.__Informar, dialogo)
        self.terminal.ejecute_script(self.install_path,
            python_path, setup, "sdist")

    def __Informar(self, terminal, dialogo):
        origen = os.path.join(self.install_path, "dist")
        for f in os.listdir(origen):
            arch = os.path.join(origen, f)
            commands.getoutput('mv %s %s' % (arch, CONFPATH))
            destino = os.path.join(CONFPATH, f)
            os.chmod(destino, 0755)
        if os.path.exists(origen):
            shutil.rmtree(origen)
        dialogo.destroy()
        t = "Proceso Concluido."
        t = "%s\n%s" % (t, "El instalador se encuentra en")
        t = "%s: %s" % (t, CONFPATH)
        # FIXME: Pedir para borrar directorio temporal ?
        dialogo = DialogoInformar(self.get_toplevel(), t)
        dialogo.run()
        dialogo.destroy()
        self.terminal.disconnect_by_func(self.__Informar)

    def __set_iconpath(self, widget, iconpath):
        new = iconpath
        if not self.install_path in iconpath:
            new = os.path.join(self.install_path, os.path.basename(iconpath))
            shutil.copyfile(iconpath, new)
        self.notebook.set_icon(new)
Esempio n. 4
0
class DebianWidget(Gtk.EventBox):

    __gtype_name__ = 'JAMediaEditorDebianWidget'

    def __init__(self, proyecto_path):

        Gtk.EventBox.__init__(self)

        archivo = os.path.join(proyecto_path, "proyecto.ide")
        arch = open(archivo, "r")
        self.proyecto = json.load(arch, "utf-8")
        arch.close()

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.notebook = Notebook(proyecto_path)
        self.install_path = os.path.join(CONFPATH, self.proyecto["nombre"])
        destino = os.path.join(self.install_path, "usr",
            "share", self.proyecto["nombre"])
        self.widgeticon = WidgetIcon("deb", destino)

        label = Gtk.Label(u"Instalador debian para: %s versión: %s" % (
            self.proyecto["nombre"], self.proyecto["version"]))
        label.modify_font(Pango.FontDescription("%s %s" % ("Monospace", 12)))
        label.modify_fg(0, Gdk.Color(0, 0, 65000))

        hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        image = Gtk.Image()
        arch = os.path.join(BASEPATH, "Iconos", "gandalftux.png")
        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(arch, 100, 100)
        image.set_from_pixbuf(pixbuf)
        hbox.pack_start(image, False, False, 0)
        vbox2 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        vbox2.pack_start(label, False, False, 0)
        vbox2.pack_start(self.widgeticon, False, False, 0)
        hbox.pack_start(vbox2, True, True, 0)
        vbox.pack_start(hbox, False, False, 0)

        vbox.pack_start(self.notebook, True, True, 0)

        self.add(vbox)
        self.show_all()

        self.widgeticon.connect("iconpath", self.__set_iconpath)
        self.widgeticon.connect("make", self.__make)

    def __make(self, widget):
        t = "Construyendo el Instalador."
        t = "%s\n%s" % (t, "Por favor espera un momento . . .")
        dialogo = DialogoLoad(self.get_toplevel(), t)
        dialogo.connect("running", self.__run_make)
        dialogo.run()

    def __run_make(self, dialogo):
        self.notebook.guardar()
        # Limpiar y establecer permisos de archivos y directorios
        get_installers_data(self.install_path)
        control = os.path.join(self.install_path, "DEBIAN", "control")
        desktop = os.path.join(self.install_path, "usr",
            "share", "applications",
            "%s.desktop" % self.proyecto["nombre"])
        lanzador = os.path.join(self.install_path, "usr", "bin",
            self.proyecto["nombre"].lower())
        for path in [control, desktop, lanzador]:
            os.chmod(path, 0755)
        destino = os.path.join(CONFPATH, "%s_%s.deb" % (
            self.proyecto["nombre"],
            self.proyecto["version"].replace(".", "_")))
        print commands.getoutput('dpkg -b %s %s' % (
            self.install_path, destino))
        os.chmod(destino, 0755)
        dialogo.destroy()
        t = "Proceso Concluido."
        t = "%s\n%s" % (t, "El instalador se encuentra en")
        t = "%s: %s" % (t, CONFPATH)
        # FIXME: Pedir para borrar directorio temporal ?
        dialogo = DialogoInformar(self.get_toplevel(), t)
        dialogo.run()
        dialogo.destroy()

    def __set_iconpath(self, widget, iconpath):
        new = iconpath
        destino = os.path.join(self.install_path, "usr",
            "share", self.proyecto["nombre"])
        if not destino in iconpath:
            new = os.path.join(destino, os.path.basename(iconpath))
            shutil.copyfile(iconpath, new)
        self.notebook.set_icon(new)