Skip to content

Commit

Permalink
fix(download): Use ladybug.config to set default download location
Browse files Browse the repository at this point in the history
With this fix, I think I can officially say that all of the [+] components that I have produced will run on Mac.
  • Loading branch information
chriswmackey committed Dec 26, 2019
1 parent eb0a5bc commit 55acb5f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions plugin/grasshopper/src/LadybugPlus_Download Weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

ghenv.Component.Name = "LadybugPlus_Download Weather"
ghenv.Component.NickName = 'downloadWeather'
ghenv.Component.Message = 'VER 0.0.04\nJUN_07_2019'
ghenv.Component.Message = 'VER 0.0.04\nDEC_25_2019'
ghenv.Component.Category = "LadybugPlus"
ghenv.Component.SubCategory = '00 :: Ladybug'
ghenv.Component.AdditionalHelpFromDocStrings = "1"
Expand All @@ -38,6 +38,7 @@
from ladybug_dotnet.download import download_file
from ladybug.futil import unzip_file
from ladybug_rhino.grasshopper import all_required_inputs
from ladybug.config import folders
except ImportError as e:
raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

Expand All @@ -53,12 +54,14 @@

# create default working_dir
if _folder_ is None:
_folder_ = os.path.join(os.environ['USERPROFILE'], 'ladybug', _folder_name)
_folder_ = folders.default_epw_folder
try:
_folder_.decode('ascii')
except UnicodeDecodeError:
raise UnicodeDecodeError('\nYour USERNAME contains a non-ASCII character, meaning files are downloaded to: \n {}'
'\nUse the _folder_ input to this component to download EPW files to a valid location.'.format(_folder_))
raise UnicodeDecodeError(
'\nYour download folder "{}" contains non-ASCII characters\n'
'\nUse the _folder_ input to this component to download EPW files'
' to a valid location.'.format(_folder_))
else:
print 'Files will be downloaded to: {}'.format(_folder_)

Expand Down
Binary file modified plugin/grasshopper/userObjects/LadybugPlus_Download Weather.ghuser
Binary file not shown.

0 comments on commit 55acb5f

Please sign in to comment.