11import os
22import subprocess
33import sys
4+ import json
45
56def run_command (command ):
67 result = subprocess .run (command , shell = True , capture_output = False , text = True )
78 if result .returncode != 0 :
89 print (f"Command failed: { command } \n Error: { result .stderr } " )
910 return result
1011
11- def update_repo (repo , order , plugin_type = 'readme' ):
12+ def update_repo (repo , order , plugin_type = 'readme' , plugin_link = "https://github.com/sccn" ):
1213 print (f"Updating { repo } ..." )
1314 current_dir = os .getcwd ()
1415 repo_path = os .path .join (current_dir , 'github' , repo )
@@ -17,15 +18,15 @@ def update_repo(repo, order, plugin_type='readme'):
1718 os .chdir (repo_path )
1819 run_command ('git pull' )
1920 else :
20- run_command (f'git clone https://github.com/sccn/ { repo } .git { repo_path } ' )
21+ run_command (f'git clone { plugin_link } .git { repo_path } ' )
2122
2223 if plugin_type == "wiki" :
2324 wiki_repo_path = f"{ repo_path } .wiki"
2425 if os .path .exists (wiki_repo_path ):
2526 os .chdir (wiki_repo_path )
2627 run_command ('git pull' )
2728 else :
28- run_command (f'git clone https://github.com/sccn/ { repo } .wiki.git { wiki_repo_path } ' )
29+ run_command (f'git clone { plugin_link } .wiki.git { wiki_repo_path } ' )
2930
3031 os .chdir (current_dir )
3132 script = 'reformat_plugin.py'
@@ -36,28 +37,26 @@ def update_repo(repo, order, plugin_type='readme'):
3637 # if 'github' not in current directory, create it
3738 if not os .path .exists ('github' ):
3839 os .makedirs ('github' )
39- wiki_plugins = ['SIFT' , 'get_chanlocs' , 'NFT' , 'EEG-BIDS' , 'nsgportal' , 'clean_rawdata' , 'amica' ]
40- readme_plugins = ['ARfitStudio' , 'roiconnect' , 'trimOutlier' , 'PACT' , 'groupSIFT' , 'nwbio' , 'ICLabel' , 'dipfit' , 'eegstats' , 'PowPowCAT' , 'PACTools' , 'zapline-plus' , 'fMRIb' , 'relica' , 'std_dipoleDensity' , 'imat' , 'viewprops' , 'cleanline' ,'NIMA' , 'firfilt' ]
41- ordering = ['ICLabel' , 'dipfit' , 'EEG-BIDS' , 'roiconnect' , 'amica' , 'cleanline' , 'clean_rawdata' , 'SIFT' , 'zapline-plus' , 'eegstats' , 'trimOutlier' , 'fMRIb' , 'imat' , 'nwbio' , 'NIMA' , 'PACT' , 'NFT' , 'PACTools' , 'ARfitStudio' , 'PowPowCAT' , 'relica' , 'std_dipoleDensity' , 'viewprops' , 'firfilt' , 'groupSIFT' , 'get_chanlocs' , 'nsgportal' ]
40+
41+ if not os .path .exists ('plugins.json' ):
42+ print ('Error: plugins.json not found.' )
43+ sys .exit (1 )
44+ plugin_info = json .load (open ('plugins.json' ))
45+ plugins = [plugin ['plugin' ] for plugin in plugin_info ]
46+ # wiki_plugins = ['SIFT', 'get_chanlocs', 'NFT', 'EEG-BIDS', 'nsgportal', 'clean_rawdata', 'amica', 'LIMO']
47+ # readme_plugins = ['ARfitStudio', 'roiconnect', 'trimOutlier', 'PACT', 'groupSIFT', 'nwbio', 'ICLabel', 'dipfit', 'eegstats', 'PowPowCAT', 'PACTools', 'zapline-plus', 'fMRIb', 'relica', 'std_dipoleDensity', 'imat', 'viewprops', 'cleanline','NIMA', 'firfilt']
48+ # ordering = ['ICLabel', 'dipfit', 'EEG-BIDS', 'roiconnect', 'amica', 'cleanline', 'clean_rawdata', 'SIFT', 'zapline-plus', 'eegstats', 'trimOutlier', 'fMRIb', 'imat', 'nwbio', 'NIMA', 'PACT', 'NFT', 'PACTools', 'ARfitStudio', 'PowPowCAT', 'relica', 'std_dipoleDensity', 'viewprops', 'firfilt', 'groupSIFT', 'get_chanlocs', 'nsgportal']
4249
4350 if len (sys .argv ) == 1 :
44- order = 1
45- for plugin in wiki_plugins :
46- update_repo (plugin , order , 'wiki' )
47- order += 1
48- for plugin in readme_plugins :
49- update_repo (plugin , order , "readme" )
50- order += 1
51+ for plugin in plugin_info :
52+ update_repo (plugin ['plugin' ], plugins .index (plugin ['plugin' ]), plugin ['type' ], plugin ['link' ])
5153 elif len (sys .argv ) == 2 :
5254 plugin_name = sys .argv [1 ]
53- if plugin_name not in wiki_plugins and plugin_name not in readme_plugins :
55+ if plugin_name not in plugins :
5456 print (f"Plugin { plugin_name } not found." )
5557 sys .exit (1 )
56-
57- plugin_type = 'wiki' if plugin_name in wiki_plugins else 'readme'
58- plugin_order = ordering .index (plugin_name ) + 1
59-
60- update_repo (plugin_name , plugin_order , plugin_type )
58+ plugin = plugin_info [plugins .index (plugin_name )]
59+ update_repo (plugin ['plugin' ], plugins .index (plugin ['plugin' ]), plugin ['type' ], plugin ['link' ])
6160 else :
6261 print ('Usage: python update_plugins.py <plugin_name>' )
6362 sys .exit (1 )
0 commit comments