1
1
import os
2
2
import subprocess
3
3
import sys
4
+ import json
4
5
5
6
def run_command (command ):
6
7
result = subprocess .run (command , shell = True , capture_output = False , text = True )
7
8
if result .returncode != 0 :
8
9
print (f"Command failed: { command } \n Error: { result .stderr } " )
9
10
return result
10
11
11
- def update_repo (repo , order , plugin_type = 'readme' ):
12
+ def update_repo (repo , order , plugin_type = 'readme' , plugin_link = "https://github.com/sccn" ):
12
13
print (f"Updating { repo } ..." )
13
14
current_dir = os .getcwd ()
14
15
repo_path = os .path .join (current_dir , 'github' , repo )
@@ -17,15 +18,15 @@ def update_repo(repo, order, plugin_type='readme'):
17
18
os .chdir (repo_path )
18
19
run_command ('git pull' )
19
20
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 } ' )
21
22
22
23
if plugin_type == "wiki" :
23
24
wiki_repo_path = f"{ repo_path } .wiki"
24
25
if os .path .exists (wiki_repo_path ):
25
26
os .chdir (wiki_repo_path )
26
27
run_command ('git pull' )
27
28
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 } ' )
29
30
30
31
os .chdir (current_dir )
31
32
script = 'reformat_plugin.py'
@@ -36,28 +37,26 @@ def update_repo(repo, order, plugin_type='readme'):
36
37
# if 'github' not in current directory, create it
37
38
if not os .path .exists ('github' ):
38
39
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']
42
49
43
50
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' ])
51
53
elif len (sys .argv ) == 2 :
52
54
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 :
54
56
print (f"Plugin { plugin_name } not found." )
55
57
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' ])
61
60
else :
62
61
print ('Usage: python update_plugins.py <plugin_name>' )
63
62
sys .exit (1 )
0 commit comments