Add version argument to freqUI installer
This commit is contained in:
parent
7b1e81689a
commit
ce9debe9fd
@ -73,7 +73,7 @@ ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit",
|
|||||||
ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url",
|
ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url",
|
||||||
"trade_source", "timeframe", "plot_auto_open"]
|
"trade_source", "timeframe", "plot_auto_open"]
|
||||||
|
|
||||||
ARGS_INSTALL_UI = ["erase_ui_only"]
|
ARGS_INSTALL_UI = ["erase_ui_only", 'ui_version']
|
||||||
|
|
||||||
ARGS_SHOW_TRADES = ["db_url", "trade_ids", "print_json"]
|
ARGS_SHOW_TRADES = ["db_url", "trade_ids", "print_json"]
|
||||||
|
|
||||||
|
@ -414,6 +414,12 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
default=False,
|
default=False,
|
||||||
),
|
),
|
||||||
|
"ui_version": Arg(
|
||||||
|
'--ui-version',
|
||||||
|
help=('Specify a specific version of FreqUI to install. '
|
||||||
|
'Not specifying this installs the latest version.'),
|
||||||
|
type=str,
|
||||||
|
),
|
||||||
# Templating options
|
# Templating options
|
||||||
"template": Arg(
|
"template": Arg(
|
||||||
'--template',
|
'--template',
|
||||||
|
@ -128,7 +128,7 @@ def download_and_install_ui(dest_folder: Path, dl_url: str, version: str):
|
|||||||
f.write(version)
|
f.write(version)
|
||||||
|
|
||||||
|
|
||||||
def get_ui_download_url() -> Tuple[str, str]:
|
def get_ui_download_url(version: Optional[str] = None) -> Tuple[str, str]:
|
||||||
base_url = 'https://api.github.com/repos/freqtrade/frequi/'
|
base_url = 'https://api.github.com/repos/freqtrade/frequi/'
|
||||||
# Get base UI Repo path
|
# Get base UI Repo path
|
||||||
|
|
||||||
@ -136,8 +136,16 @@ def get_ui_download_url() -> Tuple[str, str]:
|
|||||||
resp.raise_for_status()
|
resp.raise_for_status()
|
||||||
r = resp.json()
|
r = resp.json()
|
||||||
|
|
||||||
latest_version = r[0]['name']
|
if version:
|
||||||
assets = r[0].get('assets', [])
|
tmp = [x for x in r if x['name'] == version]
|
||||||
|
if tmp:
|
||||||
|
latest_version = tmp[0]['name']
|
||||||
|
assets = tmp[0].get('assets', [])
|
||||||
|
else:
|
||||||
|
raise ValueError("UI-Version not found.")
|
||||||
|
else:
|
||||||
|
latest_version = r[0]['name']
|
||||||
|
assets = r[0].get('assets', [])
|
||||||
dl_url = ''
|
dl_url = ''
|
||||||
if assets and len(assets) > 0:
|
if assets and len(assets) > 0:
|
||||||
dl_url = assets[0]['browser_download_url']
|
dl_url = assets[0]['browser_download_url']
|
||||||
@ -156,7 +164,7 @@ def start_install_ui(args: Dict[str, Any]) -> None:
|
|||||||
|
|
||||||
dest_folder = Path(__file__).parents[1] / 'rpc/api_server/ui/installed/'
|
dest_folder = Path(__file__).parents[1] / 'rpc/api_server/ui/installed/'
|
||||||
# First make sure the assets are removed.
|
# First make sure the assets are removed.
|
||||||
dl_url, latest_version = get_ui_download_url()
|
dl_url, latest_version = get_ui_download_url(args.get('ui_version'))
|
||||||
|
|
||||||
curr_version = read_ui_version(dest_folder)
|
curr_version = read_ui_version(dest_folder)
|
||||||
if curr_version == latest_version and not args.get('erase_ui_only'):
|
if curr_version == latest_version and not args.get('erase_ui_only'):
|
||||||
|
@ -605,16 +605,33 @@ def test_get_ui_download_url(mocker):
|
|||||||
def test_get_ui_download_url_direct(mocker):
|
def test_get_ui_download_url_direct(mocker):
|
||||||
response = MagicMock()
|
response = MagicMock()
|
||||||
response.json = MagicMock(
|
response.json = MagicMock(
|
||||||
side_effect=[[{
|
return_value=[
|
||||||
'assets_url': 'http://whatever.json',
|
{
|
||||||
'name': '0.0.1',
|
'assets_url': 'http://whatever.json',
|
||||||
'assets': [{'browser_download_url': 'http://download11.zip'}]}]])
|
'name': '0.0.2',
|
||||||
|
'assets': [{'browser_download_url': 'http://download22.zip'}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'assets_url': 'http://whatever.json',
|
||||||
|
'name': '0.0.1',
|
||||||
|
'assets': [{'browser_download_url': 'http://download1.zip'}]
|
||||||
|
},
|
||||||
|
])
|
||||||
get_mock = mocker.patch("freqtrade.commands.deploy_commands.requests.get",
|
get_mock = mocker.patch("freqtrade.commands.deploy_commands.requests.get",
|
||||||
return_value=response)
|
return_value=response)
|
||||||
x, last_version = get_ui_download_url()
|
x, last_version = get_ui_download_url()
|
||||||
assert get_mock.call_count == 1
|
assert get_mock.call_count == 1
|
||||||
|
assert last_version == '0.0.2'
|
||||||
|
assert x == 'http://download22.zip'
|
||||||
|
get_mock.reset_mock()
|
||||||
|
response.json.reset_mock()
|
||||||
|
|
||||||
|
x, last_version = get_ui_download_url('0.0.1')
|
||||||
assert last_version == '0.0.1'
|
assert last_version == '0.0.1'
|
||||||
assert x == 'http://download11.zip'
|
assert x == 'http://download1.zip'
|
||||||
|
|
||||||
|
with pytest.raises(ValueError, match="UI-Version not found."):
|
||||||
|
x, last_version = get_ui_download_url('0.0.3')
|
||||||
|
|
||||||
|
|
||||||
def test_download_data_keyboardInterrupt(mocker, caplog, markets):
|
def test_download_data_keyboardInterrupt(mocker, caplog, markets):
|
||||||
|
Loading…
Reference in New Issue
Block a user