Skip to content

Commit 2e0d8b7

Browse files
committed
Updating scripts and template
1 parent 73c34e5 commit 2e0d8b7

File tree

3 files changed

+32
-38
lines changed

3 files changed

+32
-38
lines changed
File renamed without changes.
Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
#!/bin/bash
2+
3+
# Script to generate controllers from the generated bindings file, and uses template
4+
25
currdir=`pwd`
36

47
dt=`date '+%m/%d/%Y %H:%M:%S'`
58
echo Starting ${dt}
69

7-
cd ..
8-
prevdir=`pwd`
9-
#echo prevdirectory : ${prevdir}
10-
cd ${currdir}
11-
#echo currdir : ${currdir}
12-
13-
CDIR=${prevdir}
14-
echo "CDIR=$CDIR"
15-
16-
SRCDIR=K:/sdk-python
17-
GENFOLDER=authorizenet/apicontractsv1.py #Authorize.Net/Api/Contracts/V1 #
18-
CONTROLLERFOLDER=controllerstemporary #Authorize.Net/Api/Controllers #
19-
#CONTROLLERTMP=authorizenet #Authorize.Net/Api/ #
10+
CDIR=`pwd`
11+
SRCDIR=${CDIR}
12+
GENFOLDER=authorizenet/apicontractsv1.py
13+
CONTROLLERFOLDER=controllerstemporary
2014

2115
SRCLOG=${CDIR}/log/TestSources
2216
CNTLOG=${CDIR}/log/TestControllers
@@ -29,48 +23,39 @@ else
2923
rm -rf ${CDIR}/log/*.* > /dev/null
3024
fi
3125

32-
if [ ! -e "${SRCDIR}" ];then
33-
echo Unable to find "${SRCDIR}"
34-
exit 1
35-
fi
36-
37-
38-
echo Identifying Requests\/Responses to process from "${SRCDIR}"
39-
#grep -i -e "request *=" -e "response *=" ${SRCDIR}/${GENFOLDER}/*.py | grep -v _AVS | cut -d= -f1 | egrep -v "^ |\." | sort -u > ${SRCLOG}0.log
26+
echo Identifying Requests\/Responses to process from "${SRCDIR}/${GENFOLDER}"
4027
grep -i -e "request *=" -e "response *=" ${SRCDIR}/${GENFOLDER} | grep -v _AVS | cut -d= -f1 | egrep -v "^ |\." | sort -u > ${SRCLOG}0.log
4128

4229
echo Getting Unique Request\/Responses
4330
grep -i -e "request *$" -e "response *$" ${SRCLOG}0.log > ${SRCLOG}1.log
4431

4532
echo Identifying Object names
46-
perl -pi -w -e 's/Request *$|Response *$//g;' ${SRCLOG}1.log #------------------------evaluate
33+
perl -pi -w -e 's/Request *$|Response *$//g;' ${SRCLOG}1.log
4734
sort -u ${SRCLOG}1.log > ${SRCLOG}2.log
4835

4936
# Create backup for later comparison
50-
cp ${SRCLOG}2.log ${SRCLOG}3.log >/dev/null
37+
cp ${SRCLOG}2.log ${SRCLOG}3.log
5138

5239
echo Creating Final List of Request\/Response to generate code
5340
sort -u ${SRCLOG}2.log > ${SRCLOG}.log
5441

42+
# make sure the temporary folder exists
43+
if [ ! -e "${CONTROLLERFOLDER}" ]; then
44+
mkdir ${CONTROLLERFOLDER}
45+
fi
46+
rm -rf ${CONTROLLERFOLDER}/*Controller.py
47+
5548
echo Creating Controllers
5649
for cntrls in `cat ${SRCLOG}.log`
5750
do
58-
if [ -e "${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.py" ]; then
59-
echo ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.py exists, Creating New
60-
#cp ${SRCDIR}/${CONTROLLERTMP}/ControllerTemplate.pyt ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.new
61-
cp ${SRCDIR}/ControllerTemplate.pyt ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.new
62-
perl -pi -w -e "s/APICONTROLLERNAME/$cntrls/g;" ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.new
63-
else
64-
echo Generating Code for ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.py
65-
#cp ${SRCDIR}/${CONTROLLERTMP}/ControllerTemplate.pyt ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.py
66-
cp ${SRCDIR}/ControllerTemplate.pyt ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.py
67-
perl -pi -w -e "s/APICONTROLLERNAME/$cntrls/g;" ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.py
68-
fi
51+
echo Generating Code for ${cntrls}Controller.py
52+
cp ${SRCDIR}/script/ControllerTemplate.pyt ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.py
53+
perl -pi -w -e "s/APICONTROLLERNAME/$cntrls/g;" ${SRCDIR}/${CONTROLLERFOLDER}/${cntrls}Controller.py
6954
done
7055

56+
cat ${SRCDIR}/script/headertemplate.pyt ${SRCDIR}/${CONTROLLERFOLDER}/*.py > ${SRCDIR}/authorizenet/apicontrollers.new
57+
58+
echo Controllers generated in module: ${SRCDIR}/authorizenet/apicontrollers.py
7159

72-
cat ${SRCDIR}/${CONTROLLERFOLDER}/*.py > ${SRCDIR}/${CONTROLLERFOLDER}/controllers.py
73-
cat ${SRCDIR}/${CONTROLLERFOLDER}/headertemplate.pyt ${SRCDIR}/${CONTROLLERFOLDER}/controllers.py > ${SRCDIR}/authorizenet/apicontrollers.py
60+
echo Finished ${dt}
7461

75-
echo FINISHED ${dt}
76-

script/headertemplate.pyt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'''
2+
Created on Nov 3, 2015
3+
4+
@author: krgupta
5+
'''
6+
import logging
7+
from authorizenet.constants import constants
8+
from authorizenet import apicontractsv1
9+
from authorizenet import apicontrollersbase

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy