def install(args): """docstring for install""" if not confirm_install(args): return False if "project_dir" in args and args["project_dir"] is not None: overwrite = install_epp(args) if not os.path.isdir(args["project_dir"]): os.path.makedirs(args["project_dir"]) print "Setting environment variable ..." osplus.set_env("EPP_ROOT", args["install_path"]) #osplus.set_env("EPP_PROJECT_ROOT", args["project_dir"]) # TODO Install fu, gen scripts if "formats_import_filepath" in args and args["formats_import_filepath"] is not None: print "Importing format ..." format_filepath = os.path.join(args["install_path"], "templates", "formats.xml") if os.path.isfile(format_filepath) and overwrite: print ("Deleting old Formats ...") os.remove(format_filepath) if not os.path.isfile(format_filepath): print ("Import Formats from Fusion ...") else: print ("Appending Formats from Fusion ...") import_formats(args["formats_import_filepath"], format_filepath) print "Done." print "Installing scripts ..." if "gen_script_dir" in args and args["gen_script_dir"] is not None and os.path.isdir(args["gen_script_dir"]): gen_src_dir = osplus.app_path("_scripts", "gen") copy_tree(gen_src_dir, args["gen_script_dir"]) print "Copying Generation scripts ..." else: print "Could not copy Generation scripts." if args["fu_script_dir"] is not None and os.path.isdir(args["fu_script_dir"]): gen_src_dir = osplus.app_path("_scripts", "fu") copy_tree(gen_src_dir, args["fu_script_dir"]) print "Copying Fusion scripts ..." else: print "Could not copy Fusion scripts." print "Done." # Copy exe to bin. if hasattr(sys, 'frozen'): eppbindir = os.path.join(args["install_path"], "bin") if not os.path.isdir(eppbindir): os.makedirs(eppbindir) copy_tree(osplus.app_path(), eppbindir) return True
def install_epp(args): """docstring for install_epp""" struct_file = osplus.app_path("_templates", "install.xml") print struct_file if not os.path.isfile(struct_file): return False install_path = args['install_path'] overwrite = False if not os.path.isdir(install_path): os.makedirs(install_path) else: overwrite = raw_input("Install Directory already exists. Do you want to keep old files [yes]/no? ") or "yes" not in ("yes", "y", "true") print "Creating directory strucutre ..." sh = StructHandler(struct_file, install_path, overwrite, True, args) print "Creating config file ..." sett = settings.XMLSettings( os.path.join(install_path, "config.xml") ) return overwrite
def setup_log(TITLE, DEBUG=False): """docstring for setup_log""" hostname = socket.gethostbyaddr(socket.gethostname())[0] user = getpass.getuser() # In case of debuggin use the console - else write log files if DEBUG == False: log_dir = app_path("logs") if not os.path.isdir(log_dir): os.makedirs(log_dir) log_filepath = os.path.join(log_dir,"epp_{0}_{1}.log".format(hostname, user)) logging.basicConfig(filename=log_filepath, format="%(asctime)s [%(levelname)-7s] %(message)s (%(mod)s:%(line)s)", datefmt="%Y-%m-%d %H:%M:%S") logging.getLogger().setLevel(logging.INFO) else: logging.basicConfig(format="[%(levelname)-7s] %(message)s (%(mod)s:%(line)s)", datefmt="%Y-%m-%d %H:%M:%S") logging.getLogger().setLevel(logging.DEBUG) info("------------------------------------------------") info("{0} as {1} on {2}".format(TITLE, user, hostname)) # Print to Log sl = StreamToLogger(logging.getLogger(), logging.DEBUG)