Skip to content

Commit 7876ead

Browse files
authored
Updated the download method and the WPF example (#934)
* Updated the download method and the WPF example to force download of UI and to give guidance on how to run example * Updated the download method and the WPF example to force download of UI and to give guidance on how to run example Co-authored-by: maxcapodi78 <Shark78>
1 parent 5d66d3c commit 7876ead

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

_unittest/test_00_downloads.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ def test_download_antenna_sherlock(self):
3232

3333
def test_download_wfp(self):
3434
assert self.examples.download_edb_merge_utility()
35+
assert self.examples.download_edb_merge_utility(True)

examples/00-EDB/07_WPF_Merge_Utility.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
from pyaedt.examples.downloads import download_edb_merge_utility
1717

18-
python_file = download_edb_merge_utility()
19-
18+
python_file = download_edb_merge_utility(force_download=True)
19+
desktop_version = "2022.1"
2020

2121
######################################################################
2222
# Python Script execution
@@ -35,3 +35,7 @@
3535
#
3636
# The json file contains default settings that can be used in any other project to automatically
3737
# load all settings.
38+
# The following command line can be unchecked and launched from python interpreter.
39+
40+
# from pyaedt.generic.toolkit import launch
41+
# launch(python_file, specified_version=desktop_version, new_desktop_session=False, autosave=False)

pyaedt/examples/downloads.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,17 @@ def download_aedb():
122122
return _download_file("edb/Galileo.aedb", "edb.def")
123123

124124

125-
def download_edb_merge_utility():
125+
def download_edb_merge_utility(force_download=False):
126126
"""Download an example of WPF Project which allows to merge 2aedb files.
127127
128128
Examples files are downloaded to a persistent cache to avoid
129129
re-downloading the same file twice.
130130
131+
Parameters
132+
----------
133+
force_download : bool
134+
Force to delete cache and download files again.
135+
131136
Returns
132137
-------
133138
str
@@ -137,10 +142,14 @@ def download_edb_merge_utility():
137142
--------
138143
Download an example result file and return the path of the file
139144
>>> from pyaedt import examples
140-
>>> path = examples.download_edb_mergge_utility()
145+
>>> path = examples.download_edb_merge_utility(force_download=True)
141146
>>> path
142-
'C:/Users/user/AppData/local/temp/Galileo.aedb'
147+
'C:/Users/user/AppData/local/temp/wpf_edb_merge/merge_wizard.py'
143148
"""
149+
if force_download:
150+
local_path = os.path.join(EXAMPLES_PATH, "wpf_edb_merge")
151+
if os.path.exists(local_path):
152+
shutil.rmtree(local_path, ignore_errors=True)
144153
_download_file("wpf_edb_merge/board.aedb", "edb.def")
145154
_download_file("wpf_edb_merge/package.aedb", "edb.def")
146155
_download_file("wpf_edb_merge", "merge_wizard_settings.json")

0 commit comments

Comments
 (0)