Add script to run generate distribution JSON script
This commit is contained in:
parent
c4cf047419
commit
bb112677a3
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- [ansible](playbooks/README.md#ansible-installation)
|
- [ansible](playbooks/README.md#ansible-installation)
|
||||||
- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install)
|
- [laconic-so](https://github.com/cerc-io/stack-orchestrator/?tab=readme-ov-file#install)
|
||||||
|
- Link to LPS distribution spreadsheet
|
||||||
|
|
||||||
## Export testnet state
|
## Export testnet state
|
||||||
|
|
||||||
@ -45,6 +46,14 @@
|
|||||||
|
|
||||||
- Copy over the exported `testnet-state.json` file to target machine
|
- Copy over the exported `testnet-state.json` file to target machine
|
||||||
|
|
||||||
|
- Generate LPS lockup distribution JSON file
|
||||||
|
|
||||||
|
```
|
||||||
|
bash ~/cerc/laconicd-stack/scripts/generate-lps-lock.sh "<lps-distribution-spreadsheet-url>"
|
||||||
|
```
|
||||||
|
|
||||||
|
- This will generate the `distribution.json` file at `~/cerc/laconicd-stack/distribution.json`
|
||||||
|
|
||||||
- Copy over the LPS lockup distribution `distribution.json` file to target machine
|
- Copy over the LPS lockup distribution `distribution.json` file to target machine
|
||||||
|
|
||||||
- Set envs:
|
- Set envs:
|
||||||
|
@ -15,7 +15,6 @@ def get_excel_download_url(google_sheet_url):
|
|||||||
# Export the first sheet as Excel
|
# Export the first sheet as Excel
|
||||||
return f'https://docs.google.com/spreadsheets/d/{sheet_id}/export?format=xlsx&id={sheet_id}'
|
return f'https://docs.google.com/spreadsheets/d/{sheet_id}/export?format=xlsx&id={sheet_id}'
|
||||||
|
|
||||||
|
|
||||||
def download_excel(url, output_path):
|
def download_excel(url, output_path):
|
||||||
"""
|
"""
|
||||||
Download the Excel file from the given URL.
|
Download the Excel file from the given URL.
|
||||||
@ -26,7 +25,6 @@ def download_excel(url, output_path):
|
|||||||
with open(output_path, 'wb') as f:
|
with open(output_path, 'wb') as f:
|
||||||
f.write(response.content)
|
f.write(response.content)
|
||||||
|
|
||||||
|
|
||||||
def convert_excel_to_json(excel_path, json_path):
|
def convert_excel_to_json(excel_path, json_path):
|
||||||
"""
|
"""
|
||||||
Read the Excel file, extract columns from the 'Genesis Allocation' sheet, and save as JSON.
|
Read the Excel file, extract columns from the 'Genesis Allocation' sheet, and save as JSON.
|
||||||
@ -63,7 +61,6 @@ def convert_excel_to_json(excel_path, json_path):
|
|||||||
with open(json_path, 'w') as f:
|
with open(json_path, 'w') as f:
|
||||||
json.dump(result, f, indent=2)
|
json.dump(result, f, indent=2)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) != 2:
|
if len(sys.argv) != 2:
|
||||||
print('Usage: python download_and_convert_google_sheet.py <google_sheet_url>')
|
print('Usage: python download_and_convert_google_sheet.py <google_sheet_url>')
|
||||||
@ -78,6 +75,5 @@ def main():
|
|||||||
convert_excel_to_json(excel_path, json_path)
|
convert_excel_to_json(excel_path, json_path)
|
||||||
print(f'JSON saved to {json_path}')
|
print(f'JSON saved to {json_path}')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
28
scripts/generate-lps-lock.sh
Normal file
28
scripts/generate-lps-lock.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$#" -ne 1 ]; then
|
||||||
|
echo "Usage: $0 <google_sheet_url>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sheet_url="$1"
|
||||||
|
venv_dir="$PWD/venv-lps-lock"
|
||||||
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
|
||||||
|
# Create venv if it doesn't exist
|
||||||
|
if [ ! -d "$venv_dir" ]; then
|
||||||
|
python3 -m venv "$venv_dir"
|
||||||
|
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
|
||||||
|
|
||||||
|
echo "Running LPS lock generation script..."
|
||||||
|
"$venv_dir/bin/python" "$script_dir/generate-lps-distribution-json.py" "$sheet_url"
|
||||||
|
|
||||||
|
# Clean up venv
|
||||||
|
echo "Cleaning up..."
|
||||||
|
rm -rf "$venv_dir"
|
Loading…
Reference in New Issue
Block a user