Skip to content

Commit

Permalink
Merge pull request #8 from Senzing/issue-3.dockter.1
Browse files Browse the repository at this point in the history
Shipped with SenzingAPI 2.0.0
  • Loading branch information
docktermj authored Jun 6, 2021
2 parents 090f5ff + 9b26fa4 commit 2580b59
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
[markdownlint](https://dlaa.me/markdownlint/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.4.0] - 2020-07-16

### Added to 1.4.0

- Shipped with SenzingAPI 2.0.0

## [1.3.0] - 2020-04-20

### Added to 1.3.0
Expand Down
35 changes: 12 additions & 23 deletions G2CreateProject.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def find_replace_in_file(filename, old_string, new_string):
print("Creating Senzing instance at " + target_path )

# copy opt
paths_to_exclude = [os.path.join(senzing_path, 'resources', 'config'), os.path.join(senzing_path, 'resources', 'schema')]
paths_to_exclude = []
files_to_exclude = ['G2CreateProject.py', 'G2UpdateProject.py']
def get_ignored(path, filenames):
ret = []
Expand All @@ -51,49 +51,38 @@ def get_ignored(path, filenames):

shutil.copytree(senzing_path, target_path, ignore=get_ignored)

# copy resources/templates to etc, then cut off the .template extension
files_to_ignore = shutil.ignore_patterns('G2C.db.template')
shutil.copytree(os.path.join(senzing_path,'resources', 'templates'), os.path.join(target_path, 'etc'))
# copy resources/templates to etc
files_to_ignore = shutil.ignore_patterns('G2C.db', 'setupEnv', '*.template')
shutil.copytree(os.path.join(senzing_path,'resources', 'templates'), os.path.join(target_path, 'etc'), ignore=files_to_ignore)

project_etc_path = os.path.join(target_path, 'etc')

for file in os.listdir(project_etc_path):
if file.endswith('.template'):
os.rename(os.path.join(project_etc_path, file), os.path.join(project_etc_path, file).replace('.template',''))
# copy setupEnv
shutil.copyfile(os.path.join(senzing_path, 'resources', 'templates', 'setupEnv'), os.path.join(target_path, 'setupEnv'))

# copy G2C.db to runtime location
os.makedirs(os.path.join(target_path, 'var', 'sqlite'))
shutil.copyfile(os.path.join(senzing_path, 'resources', 'templates', 'G2C.db.template'), os.path.join(target_path, 'var', 'sqlite','G2C.db'))
shutil.copyfile(os.path.join(senzing_path, 'resources', 'templates', 'G2C.db'), os.path.join(target_path, 'var', 'sqlite','G2C.db'))

# soft link in data
os.symlink('/opt/senzing/data/1.0.0', os.path.join(target_path, 'data'))

# soft link in the two resouces folders
os.symlink(os.path.join(senzing_path, 'resources', 'config'), os.path.join(target_path, 'resources', 'config'))
os.symlink(os.path.join(senzing_path, 'resources', 'schema'), os.path.join(target_path, 'resources', 'schema'))

# files to update
files_to_update = [
'setupEnv',
'etc/G2Module.ini',
'etc/G2Project.ini'
]

# paths to substitute
senzing_path_subs = [
(senzing_path, target_path),
(os.path.join(senzing_path, 'data'), os.path.join(target_path, 'data')),
('/etc/opt/senzing', os.path.join(target_path, 'etc')),
('/var/opt/senzing', os.path.join(target_path, 'var')),
('/opt/senzing', target_path),
('${SENZING_DIR}', target_path),
('${SENZING_CONFIG_DIR}', os.path.join(target_path, 'etc'))
('${SENZING_CONFIG_PATH}', os.path.join(target_path, 'etc')),
('${SENZING_DATA_DIR}', os.path.join(target_path, 'data')),
('${SENZING_RESOURCES_DIR}', os.path.join(target_path, 'resources')),
('${SENZING_VAR_DIR}', os.path.join(target_path, 'var'))
]

for f in files_to_update:
for p in senzing_path_subs:
# Anchor the replace on the character that comes before the path. This ensures that we are only
# replacing the begining of the path and not a substring of the path.
find_replace_in_file(os.path.join(target_path, f), '=' + p[0], '=' + os.path.join(target_path, p[1]))
find_replace_in_file(os.path.join(target_path, f), '@' + p[0], '@' + os.path.join(target_path, p[1]))
find_replace_in_file(os.path.join(target_path, f), p[0], p[1])

0 comments on commit 2580b59

Please sign in to comment.