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 The setup.py script allows to install Imagizer regardless to the operating system
29 """
30
31 from distutils.core import setup
32 import os, sys, glob, distutils.sysconfig, shutil, locale
33
34
35 installdir = os.path.join(distutils.sysconfig.get_python_lib(), "imagizer")
36 if os.name == 'nt':
37 execexiftran = os.path.join(os.getcwd(), "bin", "exiftran.exe")
38 ConfFile = [os.path.join(os.getenv("ALLUSERSPROFILE"), "imagizer.conf"), os.path.join(os.getenv("USERPROFILE"), "imagizer.conf")]
39 shutil.copy('selector', 'selector.py')
40 shutil.copy('generator', 'generator.py')
41 shutil.copy('imagizer.conf-windows', 'imagizer.conf')
42 scripts = ['selector.py', "generator.py", "NommeVideo.py", "ConvertIndex.descLatin1ToUTF8.py"]
43
44 elif os.name == 'posix':
45
46 ConfFile = ["/etc/imagizer.conf", os.path.join(os.getenv("HOME"), ".imagizer")]
47 scripts = ['selector', "generator", "NommeVideo.py", "ConvertIndex.descLatin1ToUTF8.py"]
48 execexiftran = os.path.join(os.getcwd(), "bin", "exiftran")
49 os.chmod(execexiftran, 509)
50 shutil.copy('imagizer.conf-unix', 'imagizer.conf')
51
52 else:
53 raise "Your platform does not seem to be an Unix nor a M$ Windows.\nI am sorry but the exiftran binary is necessary to run selector, and exiftran is probably not available for you plateform. If you have exiftran installed, please contact the developper to correct that bug, kieffer at terre-adelie dot org"
54 sys.exit(1)
55
56 configured = False
57 for i in ConfFile:
58 if os.path.isfile(i):configured = True
59
60
61
62 if len(sys.argv) == 1:
63 sys.argv.append("install")
64
65
66
67 setup(name='Imagizer',
68 version='1.0',
69 author='Jerome Kieffer',
70 author_email='Jerome.Kieffer@terre-adelie.org',
71 url='http://wiki.terre-adelie.org/Imagizer',
72 description="Imagizer is a manager for a repository of photos",
73 license='GNU GPL v2',
74 scripts=scripts,
75 data_files=[
76 (installdir, ["selector.glade", execexiftran] +
77 glob.glob(os.path.join("pixmaps", "*.png")) +
78 glob.glob(os.path.join("pixmaps", "*.ico"))),
79 (os.path.split(ConfFile[0])[0], ['imagizer.conf'])
80 ],
81 packages=['imagizer'],
82 package_dir={'imagizer': ''},
83 )
84 os.remove("imagizer.conf")
85
86 if not configured:
87 import config
88 config = config.Config()
89 config.load(ConfFile)
90
91
92
93
94
95
96
97
98
99 while True:
100 print "Enter le chemin du repertoire racine du serveur WEB :"
101 config.WebRepository = raw_input("[%s] :" % config.WebRepository)
102 if os.path.isdir(config.WebRepository):
103 break
104 print "No Such Directory"
105
106
107
108
109
110 config.Locale, config.Coding = locale.getdefaultlocale()
111 LANG = os.getenv("LANG")
112 if LANG:
113 config.Locale = LANG
114 config.PrintConfig()
115 config.SaveConfig("/etc/imagizer.conf")
116 print "Configuration finished .... Saving it\nYou can modify it in /etc/imagizer.conf"
117
118 try:
119 import pyexiv2
120 except:
121 raise ImportError("You should install pyexiv2 by: #aptitude install python-pyexiv2")
122
123 try:
124 import Image, ImageStat, ImageChops, ImageFile
125 except:
126 raise ImportError("Selector needs PIL: Python Imaging Library\n PIL is available from http://www.pythonware.com/products/pil/\ninstall it by # aptitude install python-imaging")
127 try:
128 import pygtk ; pygtk.require('2.0')
129 import gtk, gtk.glade
130 except ImportError:
131 raise ImportError("Selector needs pygtk and glade-2 available from http://www.pygtk.org/\nPLease install it with # aptitude install python-glade2")
132