From 55d5639cce6c5fc10bd0b9a0f66e3ce8a2fcbfa8 Mon Sep 17 00:00:00 2001 From: Jonathan Beal Date: Thu, 1 Jun 2017 23:04:31 -0400 Subject: [PATCH] boilerplate for new python library product --- .gitignore | 3 ++ Configuration.default | 17 ++++++++++ HISTORY | 5 +++ Install | 78 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 .gitignore create mode 100644 Configuration.default create mode 100644 HISTORY create mode 100644 Install diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9a604e4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +Configuration +*.pyc +*~ diff --git a/Configuration.default b/Configuration.default new file mode 100644 index 0000000..f6647dc --- /dev/null +++ b/Configuration.default @@ -0,0 +1,17 @@ +#!/bin/sh + +# +# Configuration.default +# + +# +# If the MGICONFIG environment variable does not have a local override, +# use the default "live" settings. +# +if [ "${MGICONFIG}" = "" ] +then + MGICONFIG=/usr/local/mgi/live/mgiconfig + export MGICONFIG +fi + +. ${MGICONFIG}/master.config.sh diff --git a/HISTORY b/HISTORY new file mode 100644 index 0000000..a9a71e9 --- /dev/null +++ b/HISTORY @@ -0,0 +1,5 @@ +TAG: none +DATE: 6/1/2017 +STAFF: jsb +CHANGES: +1) new product, initial addition diff --git a/Install b/Install new file mode 100644 index 0000000..282f04a --- /dev/null +++ b/Install @@ -0,0 +1,78 @@ +#!/bin/sh +# +# Install +########################################################################### +# +# Purpose: This script compiles all *.py files and copies both the *.py +# and the *.pyc files to the given directory. +# +# Usage: Install +# +# where +# +# library_directory is the full path of the directory where +# the *.py and *.pyc files are copied. +# +########################################################################### + +cd `dirname $0` + +# +# Source the configuration file. +# +. ./Configuration + +# +# Verify the arguments to the script. +# +if [ $# -ne 1 ] +then + echo "Usage: $0 " + exit 1 +fi +LIBRARY_DIRECTORY=$1 + +# +# If the library directory does not exist, create it. +# +if [ ! -d ${LIBRARY_DIRECTORY} ] +then + mkdir -p ${LIBRARY_DIRECTORY} + if [ $? -ne 0 ] + then + echo "Cannot create directory: ${LIBRARY_DIRECTORY}" + exit 1 + fi +fi + +# +# Compile all Python scripts. +# +python -c 'import compileall; compileall.compile_dir(".")' +if [ $? -ne 0 ] +then + echo "Error compiling Python source" + exit 1 +fi + +# +# Set the proper permissions on the Python files. +# +chmod 775 *.py +chmod 664 *.pyc + +# +# Copy the Python files to the given library directory. +# +for FILE in `ls *.py *.pyc` +do + rm -f ${LIBRARY_DIRECTORY}/${FILE} + cp -p ${FILE} ${LIBRARY_DIRECTORY} + if [ $? -ne 0 ] + then + echo "Cannot copy ${FILE} to ${LIBRARY_DIRECTORY}" + exit 1 + fi +done + +exit 0