#!/usr/bin/python #program: backup_v2_2.py - main module ################### ## IMPORTS ################### import os ################### ## FUNCTIONS ################### #newline function def newline(): print '\n' #clearscreen function (CLS is Clear screen on DOS) def cls(): os.system('clear') # splash display def splash(a): print ''' BackupPy - a python backup script Copyright (c) 2006-2007 by Sean Wahl This Software is Placed under the MIT License see LICENSE for the full text. press enter to contine ''' return a ## tests each app by running them def app_test(a, b, c): auto_menu = '' if os.system(a) == 0: auto_menu = auto_menu + 'a' elif os.system(a) == 1: auto_menu = auto_menu + x else: auto_menu = auto_menu + x if os.system(b) == 0: auto_menu = auto_menu + 'b' elif os.system(b) == 1: auto_menu = auto_menu + x else: auto_menu = auto_menu + x if os.system(c) == 0: auto_menu = auto_menu + 'c' elif os.system(c) == 1: auto_menu = auto_menu + x else: auto_menu = auto_menu + x if auto_menu == 'a': return auto_menu elif auto_menu == 'b': return auto_menu elif auto_menu == 'c': return auto_menu elif auto_menu == 'ab': return auto_menu elif auto_menu == 'ac': return auto_menu elif auto_menu == 'bc': return auto_menu elif auto_menu == 'abc': return auto_menu else: return auto_menu def zeo_found(a): if a == 'a': print ' We Found tar ........................' elif a == 'b': print ' We Found zip ........................' elif a == 'c': print ' We Found bzip2 ......................' elif a == 'ab': print ' We Found tar and zip ................' elif a == 'ac': print ' We Found tar and bzip2 ..............' elif a == 'bc': print ' We Found zip and bzip2, where\'s tar?' elif a == 'abc': print ' We Found tar, zip and bzip2 .........' else: print ' NOTHING FOUND ' def zeo_menu(a): if a == 'a': tyr_menu = 1 elif a == 'b': tyr_menu = 2 elif a == 'c': tyr_menu = 3 elif a == 'ab': tyr_menu = 12 elif a == 'ac': tyr_menu = 13 elif a == 'bc': tyr_menu = 23 elif a == 'abc': tyr_menu = 123 else: tyr_menu = 000 if tyr_menu == 'a': return tyr_menu elif tyr_menu == 'b': return tyr_menu elif tyr_menu == 'c': return tyr_menu elif tyr_menu == 'ab': return tyr_menu elif tyr_menu == 'ac': return tyr_menu elif tyr_menu == 'bc': return tyr_menu elif tyr_menu == 'abc': return tyr_menu else: return tyr_menu ####################################################### ## START OF MAIN CODE BLOCK ####################################################### ## touch the compression test, test data os.system('touch /tmp/test.me') ## setup the varibles that handle the programs prog_zip = 'zip' prog_bzip = 'bzip2' prog_tar = 'tar' #prog_gzip = #prog_lzma = ## set other varibles needed menu_type = '' blank_var=' ' app_error_var='' ## set up the command lines for the test prog_a = prog_tar + ' --help &> /dev/null' prog_b = prog_zip + ' -h &> /dev/null' prog_c = prog_bzip + ' -9fkvv /tmp/test.me &> /dev/null' #prog_d = prog_gzip + ' --help &> /dev/null' #prog_e = prog_lzma + '' ## Pass the above varibles to the test loop and return them to another ## varible for use zeo = app_test(prog_a, prog_b,prog_c) #test zeo for "not found" errors and catch them if zeo == 'error': app_error_var = 12 app_error(app_error_var) else: pass # send the zeo var's data to a func to convert to data the menu # function understands menu_type = zeo_menu(zeo) ##remove the test file os.system('rm /tmp/test.me*') # Display the Splash, # freeze the display at the spalsh screen ( how old skewl ;) print splash(blank_var) splashy = True while splashy: splash_enter = raw_input('') if splash_enter >= '': cls() splashy = False else: cls() splashy = False # print what was found app wise zeo_found(zeo) print ' Press Enter' zeofnd = True while zeofnd: zeofnd_enter = raw_input('') if zeofnd_enter >= '': cls() zeofnd = False else: cls() zeofnd = False #display menu #print menu_needed(menu_type) print zeo print menu_type, 'o-o this is not finnished at all'