-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdevede
executable file
·422 lines (354 loc) · 11 KB
/
devede
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
#!/usr/bin/env python2
# -*- 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 <http://www.gnu.org/licenses/>.
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.23.0 beta1"
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:
os.stat("/usr/share/devede/wmain.ui")
tipo=0
found=True
except:
found=False
if found==False:
try:
os.stat("/usr/local/share/devede/wmain.ui")
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"
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
global_vars["AC3_fix_ffmpeg"]=False
global_vars["AC3_fix_avconv"]=False
(a,b)=get_cores()
global_vars["cores"]=a
global_vars["hypercores"]=b
global_vars["encoder_video"]="ffmpeg"
global_vars["encoder_menu"]="mencoder"
global_vars["warning_ffmpeg"]=False
global_vars["shutdown_after_disc"]=False
global_vars["multicore"]=1 # it shouldn't use multicore by default
global_vars["hyperthreading"]=True # by default, use hyperthreading
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["encoders"]=[]
global_vars["file_blackbars"]=0
global_vars["file_lchapters"]=5
global_vars["file_sound51"]=False
global_vars["file_twopass"]=False
global_vars["file_turbo1stpass"]=False
global_vars["file_volume"]=100
#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 0==devede_other.check_program("mencoder -msglevel help"):
global_vars["encoders"].append("mencoder")
if 0==devede_other.check_program("ffmpeg --help"):
global_vars["encoders"].append("ffmpeg")
if 0==devede_other.check_program("avconv --help"):
global_vars["encoders"].append("avconv")
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 len(global_vars["encoders"])==0:
errors+="Mencoder, FFmpeg and/or AVconv"
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)
found_v=False
found_m=False
for i in global_vars["encoders"]:
if i==global_vars["encoder_video"]:
found_v=True
if i==global_vars["encoder_menu"]:
found_m=True
l=len(global_vars["encoders"])
if found_v==False:
global_vars["encoder_video"]=global_vars["encoders"][l-1]
if found_m==False:
global_vars["encoder_menu"]=global_vars["encoders"][l-1]
gtk.main()
print "Saving configuration"
devede_other.save_config(global_vars)
print "Exiting"
print "Have a nice day"
sys.stdout.flush()
sys.stderr.flush()