#!/usr/bin/python import os, sys def autoset_ccdb_home(): """The function sets $CCDB_HOME by the directory this script is in. returns the directory absolute path""" import inspect absPath = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) os.environ["CCDB_HOME"]=absPath return absPath def yes_or_no(question): possible_answers = ("y", "yes") answer = raw_input(question+" (Yes or No): ") answer = answer.lower() if answer in possible_answers: return True else: return False if (not "CCDB_HOME" in os.environ.keys()): print "Hi! I'm a virus. You've just executed me! Now you hope, that I'm just joking. And I hope, that you are under the 'root'... ok... Just joking!" print "\nI'm, simple dump script to setup your environment." print "If I will do something wrong, don't yell at me. I'm just so simple and so dump that will not understand you." print "\n\n\n" print "You dont have $CCDB_HOME. I will set it for you" ccdb_path="" if "CCDB_HOME" in os.environ and os.environ["CCDB_HOME"] != "": print "You have $CCDB_HOME It is: " ccdb_path = os.environ["CCDB_HOME"] print ccdb_path else: print "You dont have $CCDB_HOME, so I will set it for you as:" absPath=autoset_ccdb_home() print absPath if "--install" in sys.argv: result = yes_or_no("The script will just put export commands to the end of your ~/.bashrc\n continue?") if result: print("installing...") else: print "canceled!"