Update script to accept file path

This commit is contained in:
IshaVenikar 2025-06-03 11:21:43 +05:30
parent bb112677a3
commit 779af9b2e8
3 changed files with 14 additions and 10 deletions

View File

@ -4,7 +4,7 @@
- [ansible](playbooks/README.md#ansible-installation)
- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install)
- Link to LPS distribution spreadsheet
- LPS distribution spreadsheet URL or excel file path
## Export testnet state
@ -49,7 +49,7 @@
- Generate LPS lockup distribution JSON file
```
bash ~/cerc/laconicd-stack/scripts/generate-lps-lock.sh "<lps-distribution-spreadsheet-url>"
bash ~/cerc/laconicd-stack/scripts/generate-lps-lock.sh "<lps-distribution-spreadsheet-url-or-file-path>"
```
- This will generate the `distribution.json` file at `~/cerc/laconicd-stack/distribution.json`

View File

@ -63,14 +63,18 @@ def convert_excel_to_json(excel_path, json_path):
def main():
if len(sys.argv) != 2:
print('Usage: python download_and_convert_google_sheet.py <google_sheet_url>')
print('Usage: python generate-lps-distribution-json.py <google_sheet_url_or_excel_file_path>')
sys.exit(1)
google_sheet_url = sys.argv[1]
excel_url = get_excel_download_url(google_sheet_url)
excel_path = 'sheet.xlsx'
input_arg = sys.argv[1]
if input_arg.startswith('https://'):
excel_url = get_excel_download_url(input_arg)
excel_path = 'sheet.xlsx'
print(f'Downloading Excel file from: {excel_url}')
download_excel(excel_url, excel_path)
else:
excel_path = input_arg
print(f'Using Excel file at path: {excel_path}')
json_path = 'distribution.json'
print(f'Downloading Excel file from: {excel_url}')
download_excel(excel_url, excel_path)
print('Converting Excel to JSON...')
convert_excel_to_json(excel_path, json_path)
print(f'JSON saved to {json_path}')

View File

@ -17,8 +17,8 @@ if [ ! -d "$venv_dir" ]; then
fi
# Activate venv and install dependencies
"$venv_dir/bin/pip" install --upgrade pip > /dev/null
"$venv_dir/bin/pip" install requests pandas openpyxl > /dev/null
"$venv_dir/bin/pip" install --upgrade pip
"$venv_dir/bin/pip" install requests pandas openpyxl
echo "Running LPS lock generation script..."
"$venv_dir/bin/python" "$script_dir/generate-lps-distribution-json.py" "$sheet_url"