diff --git a/devede b/devede new file mode 100755 index 0000000..693e936 --- /dev/null +++ b/devede @@ -0,0 +1,420 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + +# Copyright 2006-2009 (C) Raster Software Vigo (Sergio Costas) +# Copyright 2006-2009 (C) Peter Gill - win32 parts + +# This file is part of DeVeDe +# +# DeVeDe is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# DeVeDe is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +import sys +import os +import pygtk # for testing GTK version number +pygtk.require ('2.0') +import gtk +import gobject +import subprocess +import locale +import gettext +import stat +import shutil +import pickle +import cairo + +print "DeVeDe 3.22.0beta1" +if (sys.platform!="win32") and (sys.platform!="win64"): + try: + print "Locale: "+str(os.environ["LANG"]) + except: + print "Locale not defined" + +# append the directories where we install the devede's own modules +tipo=-1 + +try: + fichero=open("./interface/wmain.ui","r") + fichero.close() + tipo=2 + found=True +except: + found=False + +if found==False: + try: + fichero=open("/usr/share/devede/wmain.ui","r") + fichero.close() + tipo=0 + found=True + except: + found=False + +if found==False: + try: + fichero=open("/usr/local/share/devede/wmain.ui","r") + fichero.close() + tipo=1 + found=True + except: + found=False + +if tipo==0: + #gettext.bindtextdomain('devede', '/usr/share/locale') + #Note also before python 2.3 you need the following if + #you need translations from non python code (glibc,libglade etc.) + #there are other access points to this function + #gtk.glade.bindtextdomain("devede","/usr/share/locale") + #arbol=gtk.Builder("/usr/share/devede/devede.glade",domain="devede") + # append the directories where we install the devede's own modules + + share_locale="/usr/share/locale" + glade="/usr/share/devede" + sys.path.append("/usr/lib/devede") + font_path="/usr/share/devede" + pic_path="/usr/share/devede" + other_path="/usr/share/devede" + help_path="/usr/share/doc/devede" + print "Using package-installed files" + +elif tipo==1: + # if the files aren't at /usr, try with /usr/local + #gettext.bindtextdomain('devede', '/usr/share/locale') + #Note also before python 2.3 you need the following if + #you need translations from non python code (glibc,libglade etc.) + #there are other access points to this function + #gtk.glade.bindtextdomain("devede","/usr/share/locale") + #arbol=gtk.Builder("/usr/local/share/devede/devede.glade",domain="devede") + + share_locale="/usr/share/locale" # Are you sure? + # if the files aren't at /usr, try with /usr/local + glade="/usr/local/share/devede" + sys.path.append("/usr/local/lib/devede") + font_path="/usr/local/share/devede" + pic_path="/usr/local/share/devede" + other_path="/usr/local/share/devede" + help_path="/usr/local/share/doc/devede" + print "Using local-installed files" + +elif tipo==2: + # if the files aren't at /usr/local, try with ./ + #gettext.bindtextdomain('devede', './po/') + #Note also before python 2.3 you need the following if + #you need translations from non python code (glibc,libglade etc.) + #there are other access points to this function + #gtk.glade.bindtextdomain("devede","/usr/share/locale") + #arbol=gtk.Builder("./devede.glade",domain="devede") + + # if the files aren't at /usr/local, try with ./ + share_locale="./po/" + glade="./interface" + sys.path.append(os.getcwd())#("./") + font_path=os.getcwd()#"./" + pic_path=os.path.join(font_path, "pixmaps") #pic_path=font_path + other_path=os.path.join(font_path,"pixmaps") + help_path=os.path.join(font_path,"doc") + print "Using direct files" + +else: + print "Can't locate extra files. Aborting." + sys.exit(1) + + +##################### +# GetText Stuff # +##################### + +gettext.bindtextdomain('devede',share_locale) +try: + locale.setlocale(locale.LC_ALL,"") +except locale.Error: + pass +gettext.textdomain('devede') +gettext.install("devede",localedir=share_locale) # None is sys default locale +# Note also before python 2.3 you need the following if +# you need translations from non python code (glibc,libglade etc.) +# there are other access points to this function +#gtk.glade.bindtextdomain("devede",share_locale) + +arbol=gtk.Builder() +arbol.set_translation_domain("devede") + +# To actually call the gettext translation functions +# just replace your strings "string" with gettext("string") +# The following shortcut are usually used: +_ = gettext.gettext + +try: + import devede_other +except: + print "Failed to load modules DEVEDE_OTHER. Exiting" + sys.exit(1) +try: + import devede_convert +except: + print "Failed to load modules DEVEDE_CONVERT. Exiting" + sys.exit(1) +try: + import devede_newfiles +except: + print "Failed to load module DEVEDE_NEWFILES. Exiting" + sys.exit(1) +try: + import devede_xml_menu +except: + print "Failed to load module DEVEDE_XML_MENU" + sys.exit(1) + +try: + import devede_disctype +except: + print "Failed to load module DEVEDE_DISCTYPE" + sys.exit(1) + +try: + import devede_fonts +except: + print "Failed to load module DEVEDE_FONTS" + sys.exit(1) + + +home=devede_other.get_home_directory() + +#locale.setlocale(locale.LC_ALL,"") +#gettext.textdomain('devede') +#_ = gettext.gettext + +# global variables used (they are stored in a single dictionary to +# avoid true global variables): +# there are these two that aren't stored in the dictionary because they are very widely used: +# arbol +# structure + +global_vars={} + +if pic_path[-1]!=os.sep: + pic_path+=os.sep + +def get_number(line): + + pos=line.find(":") + if pos==-1: + return -1 + + return int(line[pos+1:]) + +def get_cores(): + + """ Returns the number of cores available in the system """ + + try: + import multiprocessing + hyper=multiprocessing.cpu_count() + except: + hyper=1 + + if (sys.platform=="win32") or (sys.platform=="win64"): + logical_cores = win32api.GetSystemInfo()[5] #Logical Cores + return (logical_cores,logical_cores) + + failed=False + try: + proc=open("/proc/cpuinfo","r") + except: + failed=True + + + if failed: + # If can't read /proc/cpuinfo, try to use the multiprocessing module + + return (hyper,hyper) # if we can't open /PROC/CPUINFO, return only one CPU (just in case) + + siblings=1 # default values + cpu_cores=1 # for siblings and cpu cores + notfirst=False + ncores=0 + nvirtcores=0 + while(True): + line=proc.readline() + + if (((line[:9]=="processor") and notfirst) or (line=="")): + + # each entry is equivalent to CPU_CORES/SIBLINGS real cores + # (always 1 except in HyperThreading systems, where it counts 1/2) + + ncores+=(float(cpu_cores))/(float(siblings)) + siblings=1 + cpu_cores=1 + + if line=="": + break + + if line[:9]=="processor": + notfirst=True + nvirtcores+=1 + elif (line[:8]=="siblings"): + siblings=get_number(line) + elif (line[:9]=="cpu cores"): + cpu_cores=get_number(line) + + if (nvirtcores==0): + nvirtcores=1 + if(ncores<=1.0): + return (1,nvirtcores) + else: + return (int(ncores),nvirtcores) + +global_vars["PAL"]=True +global_vars["disctocreate"]="" +global_vars["path"]=pic_path +global_vars["install_path"]=other_path +global_vars["menu_widescreen"]=False +global_vars["gladefile"]=glade +global_vars["erase_temporary_files"]=True +global_vars["number_actions"]=1 +global_vars["expand_advanced"]=False +global_vars["erase_files"]=True +global_vars["action_todo"]=2 +global_vars["filmpath"]="" +global_vars["help_path"]=help_path +global_vars["finalfolder"]="" +global_vars["sub_codepage"]="ISO-8859-1" +global_vars["sub_language"]="EN (ENGLISH)" +global_vars["with_menu"]=True +global_vars["AC3_fix"]=False +(a,b)=get_cores() +global_vars["cores"]=a +global_vars["hypercores"]=b +global_vars["use_ffmpeg"]=True +global_vars["warning_ffmpeg"]=False +global_vars["shutdown_after_disc"]=False + +global_vars["menu_top_margin"]=0.125 +global_vars["menu_bottom_margin"]=0.125 +global_vars["menu_left_margin"]=0.1 +global_vars["menu_right_margin"]=0.1 +#global_vars[""]="" + +print "Cores: "+str(global_vars["cores"])+" Virtual cores: "+str(global_vars["hypercores"]) + +if font_path[-1]!=os.sep: + font_path+=os.sep +font_path+="devedesans.ttf" +global_vars["font_path"]=font_path + +print "Entro en fonts" +fonts_found=devede_fonts.prepare_devede_font(home,font_path) +print "Salgo de fonts" + +devede_other.load_config(global_vars) # load configuration + +errors="" # check for installed programs +if (sys.platform=="win32") or (sys.platform=="win64"): + try: + devede_other.check_program(["mplayer.exe", "-v"]) + except: + errors+="mplayer\n" + try: + devede_other.check_program(["mencoder.exe", "-msglevel", "help"]) + except: + errors+="mencoder\n" + try: + devede_other.check_program(["dvdauthor.exe", "--help"]) + except: + errors+="dvdauthor\n" + try: + devede_other.check_program(["vcdimager.exe", "--help"]) + except: + errors+="vcdimager\n" + try: + devede_other.check_program(["iconv.exe", "--help"]) + except: + errors+="iconv\n" + + try: + devede_other.check_program(["mkisofs.exe"]) + mkisofs=True + global_vars["iso_creator"]="mkisofs.exe" + except: + mkisofs=False + + if mkisofs==False: + try: + devede_other.check_program(["genisoimage.exe"]) + global_vars["iso_creator"]="genisoimage.exe" + except: + errors+="genisoimage/mkisofs\n" + + try: + devede_other.check_program(["spumux.exe", "--help"]) + except: + errors+="spumux\n" + +else: + + if 127==devede_other.check_program("mplayer -v"): + errors+="mplayer\n" + if 127==devede_other.check_program("mencoder -msglevel help"): + errors+="mencoder\n" + if 127==devede_other.check_program("ffmpeg --help"): + errors+="ffmpeg\n" + if 127==devede_other.check_program("dvdauthor --help"): + errors+="dvdauthor\n" + if 127==devede_other.check_program("vcdimager --help"): + errors+="vcdimager\n" + if 127==devede_other.check_program("iconv --help"): + errors+="iconv\n" + if 127==devede_other.check_program("mkisofs -help"): + if 127==devede_other.check_program("genisoimage -help"): + errors+="genisoimage/mkisofs\n" + else: + global_vars["iso_creator"]="genisoimage" + else: + global_vars["iso_creator"]="mkisofs" + + if 127==devede_other.check_program("spumux --help"): + errors+="spumux\n" + + +def program_exit(widget): + + gtk.main_quit() + + +if errors!="": + arbol.add_from_file(os.path.join(glade,"wprograms.ui")) + w=arbol.get_object("programs_label") + w.set_text(errors) + wprograms=arbol.get_object("wprograms") + wprograms.show() + w=arbol.get_object("program_exit") + w.connect("clicked",program_exit) + wprograms.connect("destroy",program_exit) +elif fonts_found==False: + arbol.add_from_file(os.path.join(glade,"wnofonts.ui")) + wprograms=arbol.get_object("wnofonts") + wprograms.show() + w=arbol.get_object("fonts_program_exit") + w.connect("clicked",program_exit) + wprograms.connect("destroy",program_exit) +else: + new_file=devede_disctype.disctype(global_vars) + +gtk.main() +print "Saving configuration" +devede_other.save_config(global_vars) +print "Exiting" +print "Have a nice day" +sys.stdout.flush() +sys.stderr.flush() diff --git a/devede.py b/devede.py deleted file mode 100755 index 693e936..0000000 --- a/devede.py +++ /dev/null @@ -1,420 +0,0 @@ -#!/usr/bin/env python -# -*- coding: UTF-8 -*- - -# Copyright 2006-2009 (C) Raster Software Vigo (Sergio Costas) -# Copyright 2006-2009 (C) Peter Gill - win32 parts - -# This file is part of DeVeDe -# -# DeVeDe is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# DeVeDe is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -import sys -import os -import pygtk # for testing GTK version number -pygtk.require ('2.0') -import gtk -import gobject -import subprocess -import locale -import gettext -import stat -import shutil -import pickle -import cairo - -print "DeVeDe 3.22.0beta1" -if (sys.platform!="win32") and (sys.platform!="win64"): - try: - print "Locale: "+str(os.environ["LANG"]) - except: - print "Locale not defined" - -# append the directories where we install the devede's own modules -tipo=-1 - -try: - fichero=open("./interface/wmain.ui","r") - fichero.close() - tipo=2 - found=True -except: - found=False - -if found==False: - try: - fichero=open("/usr/share/devede/wmain.ui","r") - fichero.close() - tipo=0 - found=True - except: - found=False - -if found==False: - try: - fichero=open("/usr/local/share/devede/wmain.ui","r") - fichero.close() - tipo=1 - found=True - except: - found=False - -if tipo==0: - #gettext.bindtextdomain('devede', '/usr/share/locale') - #Note also before python 2.3 you need the following if - #you need translations from non python code (glibc,libglade etc.) - #there are other access points to this function - #gtk.glade.bindtextdomain("devede","/usr/share/locale") - #arbol=gtk.Builder("/usr/share/devede/devede.glade",domain="devede") - # append the directories where we install the devede's own modules - - share_locale="/usr/share/locale" - glade="/usr/share/devede" - sys.path.append("/usr/lib/devede") - font_path="/usr/share/devede" - pic_path="/usr/share/devede" - other_path="/usr/share/devede" - help_path="/usr/share/doc/devede" - print "Using package-installed files" - -elif tipo==1: - # if the files aren't at /usr, try with /usr/local - #gettext.bindtextdomain('devede', '/usr/share/locale') - #Note also before python 2.3 you need the following if - #you need translations from non python code (glibc,libglade etc.) - #there are other access points to this function - #gtk.glade.bindtextdomain("devede","/usr/share/locale") - #arbol=gtk.Builder("/usr/local/share/devede/devede.glade",domain="devede") - - share_locale="/usr/share/locale" # Are you sure? - # if the files aren't at /usr, try with /usr/local - glade="/usr/local/share/devede" - sys.path.append("/usr/local/lib/devede") - font_path="/usr/local/share/devede" - pic_path="/usr/local/share/devede" - other_path="/usr/local/share/devede" - help_path="/usr/local/share/doc/devede" - print "Using local-installed files" - -elif tipo==2: - # if the files aren't at /usr/local, try with ./ - #gettext.bindtextdomain('devede', './po/') - #Note also before python 2.3 you need the following if - #you need translations from non python code (glibc,libglade etc.) - #there are other access points to this function - #gtk.glade.bindtextdomain("devede","/usr/share/locale") - #arbol=gtk.Builder("./devede.glade",domain="devede") - - # if the files aren't at /usr/local, try with ./ - share_locale="./po/" - glade="./interface" - sys.path.append(os.getcwd())#("./") - font_path=os.getcwd()#"./" - pic_path=os.path.join(font_path, "pixmaps") #pic_path=font_path - other_path=os.path.join(font_path,"pixmaps") - help_path=os.path.join(font_path,"doc") - print "Using direct files" - -else: - print "Can't locate extra files. Aborting." - sys.exit(1) - - -##################### -# GetText Stuff # -##################### - -gettext.bindtextdomain('devede',share_locale) -try: - locale.setlocale(locale.LC_ALL,"") -except locale.Error: - pass -gettext.textdomain('devede') -gettext.install("devede",localedir=share_locale) # None is sys default locale -# Note also before python 2.3 you need the following if -# you need translations from non python code (glibc,libglade etc.) -# there are other access points to this function -#gtk.glade.bindtextdomain("devede",share_locale) - -arbol=gtk.Builder() -arbol.set_translation_domain("devede") - -# To actually call the gettext translation functions -# just replace your strings "string" with gettext("string") -# The following shortcut are usually used: -_ = gettext.gettext - -try: - import devede_other -except: - print "Failed to load modules DEVEDE_OTHER. Exiting" - sys.exit(1) -try: - import devede_convert -except: - print "Failed to load modules DEVEDE_CONVERT. Exiting" - sys.exit(1) -try: - import devede_newfiles -except: - print "Failed to load module DEVEDE_NEWFILES. Exiting" - sys.exit(1) -try: - import devede_xml_menu -except: - print "Failed to load module DEVEDE_XML_MENU" - sys.exit(1) - -try: - import devede_disctype -except: - print "Failed to load module DEVEDE_DISCTYPE" - sys.exit(1) - -try: - import devede_fonts -except: - print "Failed to load module DEVEDE_FONTS" - sys.exit(1) - - -home=devede_other.get_home_directory() - -#locale.setlocale(locale.LC_ALL,"") -#gettext.textdomain('devede') -#_ = gettext.gettext - -# global variables used (they are stored in a single dictionary to -# avoid true global variables): -# there are these two that aren't stored in the dictionary because they are very widely used: -# arbol -# structure - -global_vars={} - -if pic_path[-1]!=os.sep: - pic_path+=os.sep - -def get_number(line): - - pos=line.find(":") - if pos==-1: - return -1 - - return int(line[pos+1:]) - -def get_cores(): - - """ Returns the number of cores available in the system """ - - try: - import multiprocessing - hyper=multiprocessing.cpu_count() - except: - hyper=1 - - if (sys.platform=="win32") or (sys.platform=="win64"): - logical_cores = win32api.GetSystemInfo()[5] #Logical Cores - return (logical_cores,logical_cores) - - failed=False - try: - proc=open("/proc/cpuinfo","r") - except: - failed=True - - - if failed: - # If can't read /proc/cpuinfo, try to use the multiprocessing module - - return (hyper,hyper) # if we can't open /PROC/CPUINFO, return only one CPU (just in case) - - siblings=1 # default values - cpu_cores=1 # for siblings and cpu cores - notfirst=False - ncores=0 - nvirtcores=0 - while(True): - line=proc.readline() - - if (((line[:9]=="processor") and notfirst) or (line=="")): - - # each entry is equivalent to CPU_CORES/SIBLINGS real cores - # (always 1 except in HyperThreading systems, where it counts 1/2) - - ncores+=(float(cpu_cores))/(float(siblings)) - siblings=1 - cpu_cores=1 - - if line=="": - break - - if line[:9]=="processor": - notfirst=True - nvirtcores+=1 - elif (line[:8]=="siblings"): - siblings=get_number(line) - elif (line[:9]=="cpu cores"): - cpu_cores=get_number(line) - - if (nvirtcores==0): - nvirtcores=1 - if(ncores<=1.0): - return (1,nvirtcores) - else: - return (int(ncores),nvirtcores) - -global_vars["PAL"]=True -global_vars["disctocreate"]="" -global_vars["path"]=pic_path -global_vars["install_path"]=other_path -global_vars["menu_widescreen"]=False -global_vars["gladefile"]=glade -global_vars["erase_temporary_files"]=True -global_vars["number_actions"]=1 -global_vars["expand_advanced"]=False -global_vars["erase_files"]=True -global_vars["action_todo"]=2 -global_vars["filmpath"]="" -global_vars["help_path"]=help_path -global_vars["finalfolder"]="" -global_vars["sub_codepage"]="ISO-8859-1" -global_vars["sub_language"]="EN (ENGLISH)" -global_vars["with_menu"]=True -global_vars["AC3_fix"]=False -(a,b)=get_cores() -global_vars["cores"]=a -global_vars["hypercores"]=b -global_vars["use_ffmpeg"]=True -global_vars["warning_ffmpeg"]=False -global_vars["shutdown_after_disc"]=False - -global_vars["menu_top_margin"]=0.125 -global_vars["menu_bottom_margin"]=0.125 -global_vars["menu_left_margin"]=0.1 -global_vars["menu_right_margin"]=0.1 -#global_vars[""]="" - -print "Cores: "+str(global_vars["cores"])+" Virtual cores: "+str(global_vars["hypercores"]) - -if font_path[-1]!=os.sep: - font_path+=os.sep -font_path+="devedesans.ttf" -global_vars["font_path"]=font_path - -print "Entro en fonts" -fonts_found=devede_fonts.prepare_devede_font(home,font_path) -print "Salgo de fonts" - -devede_other.load_config(global_vars) # load configuration - -errors="" # check for installed programs -if (sys.platform=="win32") or (sys.platform=="win64"): - try: - devede_other.check_program(["mplayer.exe", "-v"]) - except: - errors+="mplayer\n" - try: - devede_other.check_program(["mencoder.exe", "-msglevel", "help"]) - except: - errors+="mencoder\n" - try: - devede_other.check_program(["dvdauthor.exe", "--help"]) - except: - errors+="dvdauthor\n" - try: - devede_other.check_program(["vcdimager.exe", "--help"]) - except: - errors+="vcdimager\n" - try: - devede_other.check_program(["iconv.exe", "--help"]) - except: - errors+="iconv\n" - - try: - devede_other.check_program(["mkisofs.exe"]) - mkisofs=True - global_vars["iso_creator"]="mkisofs.exe" - except: - mkisofs=False - - if mkisofs==False: - try: - devede_other.check_program(["genisoimage.exe"]) - global_vars["iso_creator"]="genisoimage.exe" - except: - errors+="genisoimage/mkisofs\n" - - try: - devede_other.check_program(["spumux.exe", "--help"]) - except: - errors+="spumux\n" - -else: - - if 127==devede_other.check_program("mplayer -v"): - errors+="mplayer\n" - if 127==devede_other.check_program("mencoder -msglevel help"): - errors+="mencoder\n" - if 127==devede_other.check_program("ffmpeg --help"): - errors+="ffmpeg\n" - if 127==devede_other.check_program("dvdauthor --help"): - errors+="dvdauthor\n" - if 127==devede_other.check_program("vcdimager --help"): - errors+="vcdimager\n" - if 127==devede_other.check_program("iconv --help"): - errors+="iconv\n" - if 127==devede_other.check_program("mkisofs -help"): - if 127==devede_other.check_program("genisoimage -help"): - errors+="genisoimage/mkisofs\n" - else: - global_vars["iso_creator"]="genisoimage" - else: - global_vars["iso_creator"]="mkisofs" - - if 127==devede_other.check_program("spumux --help"): - errors+="spumux\n" - - -def program_exit(widget): - - gtk.main_quit() - - -if errors!="": - arbol.add_from_file(os.path.join(glade,"wprograms.ui")) - w=arbol.get_object("programs_label") - w.set_text(errors) - wprograms=arbol.get_object("wprograms") - wprograms.show() - w=arbol.get_object("program_exit") - w.connect("clicked",program_exit) - wprograms.connect("destroy",program_exit) -elif fonts_found==False: - arbol.add_from_file(os.path.join(glade,"wnofonts.ui")) - wprograms=arbol.get_object("wnofonts") - wprograms.show() - w=arbol.get_object("fonts_program_exit") - w.connect("clicked",program_exit) - wprograms.connect("destroy",program_exit) -else: - new_file=devede_disctype.disctype(global_vars) - -gtk.main() -print "Saving configuration" -devede_other.save_config(global_vars) -print "Exiting" -print "Have a nice day" -sys.stdout.flush() -sys.stderr.flush() diff --git a/devede.py b/devede.py new file mode 120000 index 0000000..ae1ad34 --- /dev/null +++ b/devede.py @@ -0,0 +1 @@ +devede \ No newline at end of file diff --git a/install.sh b/install.sh deleted file mode 100755 index 620873c..0000000 --- a/install.sh +++ /dev/null @@ -1,160 +0,0 @@ -#!/bin/bash - -# Get script directory path. - -scriptdir="`dirname ${0}`" -DESTDIR="${DESTDIR:-}" - - -install_lang() # arg1=datadir, arg2=locale, arg3=. - -{ - install -m 755 -d "${DESTDIR}${1}/locale/${2}/LC_MESSAGES" - install -m 644 "${scriptdir}/po/${3}.mo" \ - "${DESTDIR}${1}/locale/${2}/LC_MESSAGES/devede.mo" -} - - -install_locales() # arg1=datadir. - -{ - install_lang "${1}" ca ca # Catala - install_lang "${1}" cs cs_CZ # Czech - install_lang "${1}" da da # Danish - install_lang "${1}" de_DE de_DE # German - install_lang "${1}" el el # Greek - install_lang "${1}" es es # Spanish - install_lang "${1}" fr fr # French - install_lang "${1}" gl gl # Galego - install_lang "${1}" hu_HU hu_HU # Hungarian - install_lang "${1}" it_IT it_IT # Italian - install_lang "${1}" nb_NO nb_NO # Norwegian - install_lang "${1}" nl nl # Netherlands - install_lang "${1}" pl pl # Poland - install_lang "${1}" pt_BR pt_BR # Brazilian portugues. - install_lang "${1}" pt_PT pt_PT # Portugues - install_lang "${1}" ru ru # Russian - install_lang "${1}" sk sk # Slovak - install_lang "${1}" sv sv # - install_lang "${1}" tr tr # Turkish - install_lang "${1}" zh_TW zh_TW # Taiwanese - install_lang "${1}" zh_CN zh_CN # Simplified Chinese -} - - -install_others() # arg1=bindir, arg2=datadir, arg3=pkglibdir, - # arg4=pkgdatadir, arg5=pkgdocdir. - -{ - install -m 755 -d "${DESTDIR}${1}" - install -m 755 "${scriptdir}/devede.py" "${DESTDIR}${1}/devede" - install -m 755 "${scriptdir}/devede_debug" "${DESTDIR}${1}/devede_debug" - install -m 755 "${scriptdir}/devede-debug" "${DESTDIR}${1}/devede-debug" - - install -m 755 -d "${DESTDIR}${3}" - install "${scriptdir}"/devede_*.py "${DESTDIR}${3}/" - - install -m 755 -d "${DESTDIR}${4}" - install -m 755 -d "${DESTDIR}${4}/backgrounds" - install -m 644 "${scriptdir}/interface"/* "${DESTDIR}${4}/" - install -m 644 "${scriptdir}/devedesans.ttf" "${DESTDIR}${4}/" - install -m 644 "${scriptdir}/pixmaps"/* "${DESTDIR}${4}/" 2>/dev/null - install -m 644 "${scriptdir}/pixmaps/backgrounds"/* "${DESTDIR}${4}/backgrounds/" - install -m 644 "${scriptdir}/devede.svg" "${DESTDIR}${4}/" - - install -m 755 -d "${DESTDIR}${2}/pixmaps" - install -m 644 "${scriptdir}/devede.svg" "${DESTDIR}${2}/pixmaps/" - - install -m 755 -d "${DESTDIR}${2}/pixmaps/backgrounds" - install -m 644 "${scriptdir}/devede.svg" "${DESTDIR}${2}/pixmaps/" - - install -m 755 -d "${DESTDIR}${2}/applications" - install -m 644 "${scriptdir}/devede.desktop" \ - "${DESTDIR}${2}/applications/" - - install -m 755 -d "${DESTDIR}${5}" - install -m 644 "${scriptdir}/docs"/c* "${DESTDIR}${5}" - - install -m 755 -d "${DESTDIR}${5}/html" - install -m 644 "${scriptdir}/docs/html"/* "${DESTDIR}${5}/html" - -} - - -# Process arguments. - -PARAM= - -for arg -do if [ "${PARAM}" ] - then eval "${PARAM}=\"${arg}\"" - PARAM= - else - case "${arg}" in - - --*) PARAM="${arg: 2}" - ;; - - -*) PARAM="${arg: 1}" - ;; - - *) PARAM="${arg}" - ;; - esac - - case "${PARAM}" in - - *=*) eval "${PARAM}" - PARAM= - ;; - esac - fi -done - -if [ "${PARAM}" ] -then eval "${PARAM}=" -fi - -# Uninstall older versions if needed. - -[ "${uninstall}" = "no" ] || "${scriptdir}/uninstall.sh" "${@}" - -# Version is targeted if specified as such, or if a parameter is set. - -targeted=${targeted:-${prefix}${bindir}${libdir}${datadir}${docdir}\ -${pkglibdir}${pkgdatadir}${pkgdocdir}${DESTDIR}no} - -if [ "${targeted}" = "no" ] -then - # Version is not targeted. Install new version to the default - # paths (relative to DESTDIR). - - install_locales "/usr/share" # Locales are common. - - install_others "/usr/local/bin" \ - "/usr/local/share" \ - "/usr/local/lib/devede" \ - "/usr/local/share/devede" \ - "/usr/local/share/doc/devede" -else - - # Be sure all paths are defined. - - prefix="${prefix:-/usr/local}" - bindir="${bindir:-${prefix}/bin}" - libdir="${libdir:-${prefix}/lib}" - datadir="${datadir:-${prefix}/share}" - docdir="${docdir:-${datadir}/doc}" - pkglibdir="${pkglibdir:-${libdir}/devede}" - pkgdatadir="${pkgdatadir:-${datadir}/devede}" - pkgdocdir="${pkgdocdir:-${docdir}/devede}" - - # And now, install everything according to paths above. - - install_locales "${datadir}" - install_others "${bindir}" \ - "${datadir}" \ - "${pkglibdir}" \ - "${pkgdatadir}" \ - "${pkgdocdir}" -fi diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..560c6ee --- /dev/null +++ b/setup.py @@ -0,0 +1,66 @@ +#!/usr/bin/python + +import os +from glob import glob +from distutils.core import setup +from distutils import dep_util + +def get_mopath(pofile): + # Function to determine right locale path for a .po file + lang = os.path.basename(pofile)[:-3] # len('.po') == 3 + modir = os.path.join('locale', lang, 'LC_MESSAGES') # e.g. locale/fr/LC_MESSAGES/ + mofile = os.path.join(modir, 'devede.mo') # e.g. locale/fr/LC_MESSAGES/devede.mo + return modir, mofile + +def get_data_files(): + data_files = [ + (os.path.join('share', 'applications'), ['devede.desktop']), + (os.path.join('share', 'pixmaps'), ['devede.svg']), + (os.path.join('share', 'devede'), glob("interface/*")), + (os.path.join('share', 'devede'), glob('pixmaps/*g')), + (os.path.join('share', 'devede'), ['devede.svg']), + (os.path.join('share', 'devede'), ['devedesans.ttf']), + (os.path.join('share', 'devede', 'backgrounds'), glob('pixmaps/backgrounds/*')), + (os.path.join('share', 'doc', 'devede', 'html'), glob('docs/html/*')) + ] + + for pofile in [f for f in os.listdir('po') if f.endswith('.po')]: + pofile = os.path.join('po', pofile) # po/fr.po + modir, mofile = get_mopath(pofile) + target = os.path.join('share', modir) # share/locale/fr/LC_MESSAGES/ + data_files.append((target, [mofile])) + + return data_files + +def get_py_modules(): + return [i.replace(".py","") for i in glob("devede_*.py")] + +def compile_translations(): + for pofile in [f for f in os.listdir('po') if f.endswith('.po')]: + pofile = os.path.join('po', pofile) + modir, mofile = get_mopath(pofile) + + # create an architecture for these locales + if not os.path.isdir(modir): + os.makedirs(modir) + + if not os.path.isfile(mofile) or dep_util.newer(pofile, mofile): + print 'compiling %s' % mofile + # msgfmt.make(pofile, mofile) + os.system("msgfmt \"" + pofile + "\" -o \"" + mofile + "\"") + else: + print 'skipping %s - up to date' % mofile + +compile_translations() + +setup( + name = 'devede', + version = '3.21.0', + author = "Sergio Costas", + author_email = "raster@rastersoft.com", + url = "http://www.rastersoft.com/programas/devede.html", + license = 'GPL-3', + py_modules = get_py_modules(), + scripts=['devede'], + data_files = get_data_files() +) diff --git a/uninstall.sh b/uninstall.sh deleted file mode 100755 index 9f39ff3..0000000 --- a/uninstall.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/bash - - -uninstall_locales() # arg1=datadir. - -{ - rm -f "${DESTDIR}${1}/locale/"*"/LC_MESSAGES/devede.mo" -} - - -uninstall_others() # arg1=bindir, arg2=datadir, arg3=pkglibdir, - # arg4=pkgdatadir, arg5=pkgdocdir. - -{ - rm -f "${DESTDIR}${1}/devede" - rm -f "${DESTDIR}${1}/devede.py" - rm -f "${DESTDIR}${1}/devede_debug" - rm -rf "${DESTDIR}${3}" - rm -rf "${DESTDIR}${4}" - rm -rf "${DESTDIR}${5}" - rm -f "${DESTDIR}${2}/pixmaps/devede.png" - rm -f "${DESTDIR}${2}/pixmaps/devede.svg" - rm -f "${DESTDIR}${2}/applications/devede.desktop" -} - - -# Process arguments. - -PARAM= - -for arg -do if [ "${PARAM}" ] - then eval "${PARAM}=\"${arg}\"" - PARAM= - else - case "${arg}" in - - --*) PARAM="${arg: 2}" - ;; - - -*) PARAM="${arg: 1}" - ;; - - *) PARAM="${arg}" - ;; - esac - - case "${PARAM}" in - - *=*) eval "${PARAM}" - PARAM= - ;; - esac - fi -done - -if [ "${PARAM}" ] -then eval "${PARAM}=" -fi - -DESTDIR="${DESTDIR:-}" - -# Version is targeted if specified as such, or if a parameter is set. - -targeted=${targeted:-${prefix}${bindir}${libdir}${datadir}${docdir}\ -${pkglibdir}${pkgdatadir}${pkgdocdir}${DESTDIR}no} - -if [ "${targeted}" = "no" ] -then - # Version is not targeted. Uninstall legacy and current versions - # in default paths (relative to DESTDIR). - - uninstall_locales "/usr/share" # Locales are common. - - # Remove legacy version. - - uninstall_others "/usr/bin" \ - "/usr/share" \ - "/usr/lib/devede" \ - "/usr/share/devede" \ - "/usr/share/doc/devede" - - # Remove current version. - - uninstall_others "/usr/local/bin" \ - "/usr/local/share" \ - "/usr/local/lib/devede" \ - "/usr/local/share/devede" \ - "/usr/local/share/doc/devede" -else - # Be sure all paths are defined. - - prefix="${prefix:-/usr/local}" - bindir="${bindir:-${prefix}/bin}" - libdir="${libdir:-${prefix}/lib}" - datadir="${datadir:-${prefix}/share}" - docdir="${docdir:-${datadir}/doc}" - pkglibdir="${pkglibdir:-${libdir}/devede}" - pkgdatadir="${pkgdatadir:-${datadir}/devede}" - pkgdocdir="${pkgdocdir:-${docdir}/devede}" - - # Remove targeted version. - - uninstall_locales "${datadir}" - uninstall_others "${bindir}" \ - "${datadir}" \ - "${pkglibdir}" \ - "${pkgdatadir}" \ - "${pkgdocdir}" -fi