~klnavarro98/earth17/trunk

« back to all changes in this revision

Viewing changes to src/earth17.py

  • Committer: klnavarro
  • Date: 2008-11-12 00:18:20 UTC
  • Revision ID: mickey@bunny-20081112001820-24bc074df4737646
Remove install command.

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
#
206
206
# Main entry point.
207
207
#
208
 
def main(cmd, options):
 
208
def main(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.
214
 
    
215
 
    install: install all needed files (use setup.py instead)
216
 
    run:     generate and update e17 backgrounds"""
217
 
 
218
 
    if cmd == 'install':
219
 
        print "Initiate Earth17 environment... ",
220
 
        
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
224
 
 
225
 
        # Copy MAIN program
226
 
        shutil.copy("src/earth17.py", options.confdir)
227
 
 
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)
234
 
        # Maps -> Images
235
 
        shutil.copytree("map", os.path.join(options.confdir, "images"))
236
 
 
237
 
        print options.confdir
238
 
 
239
 
    elif cmd == 'run':
240
 
        os.nice(NICE)  # go to background
241
 
 
242
 
        while(True):
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!"
249
 
                break
250
 
        
251
 
            # Download clouds map
252
 
            download_clouds(options.confdir, CLOUDS_MAP)
253
 
 
254
 
            # Generate background image using XPlanet
255
 
            generate_xplanet(options.confdir, XPLANET_CFG, XPLANET_IMG)
256
 
    
257
 
            # Update earth17.edc and compile edj file
258
 
            compile_edje(options.confdir, XPLANET_IMG)
259
 
 
260
 
            # Update enlightenment backgrounds
261
 
            set_backgrounds(options.confdir, XPLANET_IMG)
262
 
 
263
 
            # Wait next run...
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)
268
 
 
269
 
        print "Bye."
 
213
    - And, update enlightenment backgrounds."""
 
214
    
 
215
    os.nice(NICE)  # go to background
 
216
 
 
217
    while(True):
 
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!"
 
224
            break
 
225
        
 
226
        # Download clouds map
 
227
        download_clouds(options.confdir, CLOUDS_MAP)
 
228
 
 
229
        # Generate background image using XPlanet
 
230
        generate_xplanet(options.confdir, XPLANET_CFG, XPLANET_IMG)
 
231
    
 
232
        # Update earth17.edc and compile edj file
 
233
        compile_edje(options.confdir, XPLANET_IMG)
 
234
 
 
235
        # Update enlightenment backgrounds
 
236
        set_backgrounds(options.confdir, XPLANET_IMG)
 
237
 
 
238
        # Wait next run...
 
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)
 
243
 
 
244
    print "Bye."
270
245
 
271
246
 
272
247
#
287
262
                    help="XPlanet config (%s)" % os.path.join(EARTH17_CONFDIR, XPLANET_CFG)),
288
263
        ]
289
264
 
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)
294
269
 
295
270
    (options, args) = parser.parse_args()
296
271
 
297
 
    # Needed action
298
 
    if not args:
299
 
        parser.error("missing command argument ('install' or 'run')!")
300
 
    elif len(args) != 1:
301
 
        parser.error("incorrect number of arguments!")
302
 
    else:
303
 
        if args[0] not in ['install', 'run']:
304
 
            parser.error("invalid command '%s'!" % args[0])
305
 
 
306
272
    # Compulsory options
307
273
    if not options.confdir:
308
274
        paser.error("missing install_dir option!")
309
275
 
310
276
    # Process start here
311
 
    main(args[0], options)
 
277
    main(options)