Newer
Older
# -*- coding: utf-8 -*-
"""Prepare the zip file for the model
"""
import os
import shutil
import subprocess
from refutils import (turb_to_hs2, turb_to_step, delete_dlls, clone_repo,
get_repo_info)
if __name__ == '__main__':
# script inputs
mod_dir = '../dtu-10mw-rwt/' # must end with slash
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
basename = 'DTU_10MW_RWT'
dll_git_url = 'https://gitlab.windenergy.dtu.dk/OpenLAC/control-binary/control-win32.git'
dll_branch = 'ref_models'
dll_list = [('dtu_we_controller.dll', 'dtu_we_controller.dll'),
('generator_servo.dll', 'generator_servo.dll'),
('mech_brake.dll', 'mech_brake.dll'),
('servo_with_limits.dll', 'servo_with_limits.dll'),
('towerclearance_mblade.dll', 'towerclearance_mblade.dll')]
# ======= make hawcstab2 and step-wind files =======
htc_base = mod_dir + f'htc/{basename}.htc'
kwargs = {} # default kwargs in functions are for DTU 10 MW, no need to update
# hawcstab2
hs2_path = mod_dir + f'{basename}_hs2.htc'
turb_to_hs2(htc_base, hs2_path, **kwargs)
# step wind
step_path = mod_dir + f'htc/{basename}_step.htc'
turb_to_step(htc_base, step_path, **kwargs)
# ======= clone dll repo and copy in the ones we need =======
control_dir = mod_dir + 'control/' # must end with slash!
# delete dlls in control repo
try: # if control folder exists, delete dlls
delete_dlls(control_dir)
except FileNotFoundError: # if control folder doesn't exist, create it
os.mkdir(control_dir)
# clone dll repo (will throw error if repo not deleted)
clone_repo(dll_git_url, dll_branch)
# copy dlls to control repo
[shutil.copy('control-win32/' + t[0], control_dir + t[1])
for t in dll_list]
# delete control binaries
shutil.rmtree('./control-win32/') # doesn't work on WINDOWS >:(
#subprocess.run(['rmdir', '/s', '/q', 'control-win32'], shell=True, check=True)
#url, branch, commit, date = get_repo_info()
#with open(mod_dir + 'git_version.txt', 'w') as f:
# f.write(f'Git info for {basename} zip file\n')
# f.write('------------------------------------\n')
# f.write('Automatically generated using CI on following repo.\n\n')
# f.write(f'Repo url: {url}\n')
# f.write(f'Branch: {branch}\n')
# f.write(f'Commit: {commit} made on {date}\n')
# ======= make the archive =======
shutil.make_archive(mod_dir, 'zip', zip_name)
#%%