Spaces:
Running
Running
File size: 855 Bytes
0c3cfb8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import os
import subprocess
import sys
from urllib.parse import quote
def main():
token = os.environ.get('GITHUB')
if not token:
print('Error: GITHUB environment variable not set')
sys.exit(1)
token_encoded = quote(token, safe='')
clone_url = f'https://{token_encoded}@github.com/johnpaulbin/flashcards.git'
print(f'Cloning')
try:
subprocess.run(['git', 'clone', clone_url], check=True)
except subprocess.CalledProcessError as e:
print(f'Error cloning repository: {e}')
sys.exit(1)
# Change directory to the cloned repo
os.chdir('flashcards')
# Run app.py
try:
subprocess.run(['python', 'app.py'], check=True)
except subprocess.CalledProcessError as e:
print(f'Error running app.py: {e}')
sys.exit(1)
if __name__ == '__main__':
main() |