206
206
# Main entry point.
208
def main(cmd, options):
209
209
"""Generate e17 backgrounds using XPlanet:
210
210
- Download coulds image from mirrors;
211
211
- Generate background image using XPlanet;
212
212
- Update earth17.edc and compile edj file;
213
- And, update enlightenment backgrounds.
215
install: install all needed files (use setup.py instead)
216
run: generate and update e17 backgrounds"""
219
print "Initiate Earth17 environment... ",
221
if os.access(options.confdir, os.R_OK and os.W_OK):
222
shutil.rmtree(options.confdir)
223
os.mkdir(options.confdir, 0755) # create conf dir
226
shutil.copy("src/earth17.py", options.confdir)
228
# Copy XPlanet conf and map files
229
if options.xplanet_cfg:
230
#print "Using XPlanet conf file '%s'" % options.xplanet_cfg
231
shutil.copy(options.xplanet_cfg, options.confdir)
232
else: # default XPlanet conf
233
shutil.copy(os.path.join("cfg", XPLANET_CFG), options.confdir)
235
shutil.copytree("map", os.path.join(options.confdir, "images"))
237
print options.confdir
240
os.nice(NICE) # go to background
243
# Set the new background, unless enlightenment has been stopped
244
enlightenment_processes = os.popen('ps -e |grep " enlightenment$" | sed -e "s/^ *\([0-9]*\).*/\1/g"')
245
enlightenment_pid = enlightenment_processes.readline().strip()
246
enlightenment_processes.close()
247
if not enlightenment_pid:
248
print "Enlightenment not running!"
251
# Download clouds map
252
download_clouds(options.confdir, CLOUDS_MAP)
254
# Generate background image using XPlanet
255
generate_xplanet(options.confdir, XPLANET_CFG, XPLANET_IMG)
257
# Update earth17.edc and compile edj file
258
compile_edje(options.confdir, XPLANET_IMG)
260
# Update enlightenment backgrounds
261
set_backgrounds(options.confdir, XPLANET_IMG)
264
curr_date = datetime.now()
265
next_date = curr_date + timedelta(seconds=SLEEP_TIME)
266
print "Sleep until... " + next_date.strftime("%Y%m%dT%H%M%S")
267
time.sleep(SLEEP_TIME)
213
- And, update enlightenment backgrounds."""
215
os.nice(NICE) # go to background
218
# Set the new background, unless enlightenment has been stopped?
219
enlightenment_processes = os.popen('ps -e |grep " enlightenment$" | sed -e "s/^ *\([0-9]*\).*/\1/g"')
220
enlightenment_pid = enlightenment_processes.readline().strip()
221
enlightenment_processes.close()
222
if not enlightenment_pid:
223
print "Enlightenment not running!"
226
# Download clouds map
227
download_clouds(options.confdir, CLOUDS_MAP)
229
# Generate background image using XPlanet
230
generate_xplanet(options.confdir, XPLANET_CFG, XPLANET_IMG)
232
# Update earth17.edc and compile edj file
233
compile_edje(options.confdir, XPLANET_IMG)
235
# Update enlightenment backgrounds
236
set_backgrounds(options.confdir, XPLANET_IMG)
239
curr_date = datetime.now()
240
next_date = curr_date + timedelta(seconds=SLEEP_TIME)
241
print "Sleep until... " + next_date.strftime("%Y%m%dT%H%M%S")
242
time.sleep(SLEEP_TIME)
287
262
help="XPlanet config (%s)" % os.path.join(EARTH17_CONFDIR, XPLANET_CFG)),
290
parser = OptionParser(usage="python -O %prog [options] ... install|run",
265
parser = OptionParser(usage="python -O %prog [options] ...",
291
266
version=__version__,
292
267
description="Generate e17 backgrounds using XPlanet.",
293
268
option_list=option_list)
295
270
(options, args) = parser.parse_args()
299
parser.error("missing command argument ('install' or 'run')!")
301
parser.error("incorrect number of arguments!")
303
if args[0] not in ['install', 'run']:
304
parser.error("invalid command '%s'!" % args[0])
306
272
# Compulsory options
307
273
if not options.confdir:
308
274
paser.error("missing install_dir option!")
310
276
# Process start here
311
main(args[0], options)