1+ # Python script to download the latest release of PhysiCell Studio. It will create a /studio directory
2+ # from wherever this script is run. Sample commands to run the Studio will be printed.
3+
4+ import requests
5+ import os
6+ import zipfile
7+ import shutil
8+
9+ response = requests .get ("https://api.github.com/repos/PhysiCell-Tools/PhysiCell-Studio/releases/latest" )
10+ release_name_str = response .json ()["name" ]
11+ print (release_name_str )
12+ print (release_name_str .split ())
13+ vnum = release_name_str .split ()[0 ]
14+ print ("vnum=" ,vnum ) # e.g., vnum= v2.26.7
15+
16+
17+ try :
18+ os .system ('rm -rf studio' )
19+ except :
20+ pass
21+
22+ # PhysiCell-Studio-2.26.7
23+ remote_url = 'https://github.com/PhysiCell-Tools/PhysiCell-Studio/archive/refs/tags/' + vnum + '.zip'
24+ print ("remote_url=" ,remote_url )
25+ local_file = 'Studio.zip'
26+ data = requests .get (remote_url )
27+ with open (local_file , 'wb' )as file :
28+ file .write (data .content )
29+ print ("downloaded version " ,vnum ," to " ,local_file )
30+
31+ print ("unzip-ing " ,local_file )
32+ with zipfile .ZipFile (local_file , 'r' ) as zip_ref :
33+ zip_ref .extractall ("." )
34+
35+ latest_studio_dir = "PhysiCell-Studio-" + vnum [1 :] # need to drop the 'v' as first character
36+ shutil .move (latest_studio_dir ,"studio" )
37+ print (f"renamed '{ latest_studio_dir } ' to 'studio'" )
38+
39+ print ("\n -- Sample commands to run the Studio:" )
40+ print ("python studio/bin/studio.py # attempts to load config/PhysiCell_settings.xml" )
41+ print ("python studio/bin/studio.py -c <config_file.xml> -e <executable_program>" )
42+ print ("python studio/bin/studio.py --help" )
43+ print ()
0 commit comments