File tree Expand file tree Collapse file tree 8 files changed +33
-28
lines changed Expand file tree Collapse file tree 8 files changed +33
-28
lines changed Original file line number Diff line number Diff line change 17
17
""""""
18
18
19
19
from openplugin .install .local_install import install_local_plugin
20
- from openplugin .install .zip_install import install_zip_plugin
21
20
from openplugin .install .remote_install import remote_install
22
21
from openplugin .install .uninstall import uninstall_plugin
22
+ from openplugin .install .zip_install import install_zip_plugin
23
+
24
+
23
25
def install_plugin (plugin_name : str ) -> bool :
24
26
if plugin_name == "./" or plugin_name == "." :
25
27
print ("Installing current directory as plugin..." )
@@ -31,8 +33,7 @@ def install_plugin(plugin_name: str) -> bool:
31
33
32
34
return remote_install (plugin_name )
33
35
36
+
34
37
def reinstall_plugin (plugin_name : str ) -> bool :
35
38
uninstall_plugin (plugin_name )
36
39
return install_plugin (plugin_name )
37
-
38
-
Original file line number Diff line number Diff line change 16
16
17
17
""""""
18
18
from openplugin .utils .util import (
19
+ get_plugin_directory ,
19
20
get_plugin_list ,
20
21
get_plugin_version ,
21
- get_plugin_directory ,
22
22
)
23
23
24
24
@@ -27,5 +27,5 @@ def list_plugins() -> bool:
27
27
plugin_directory = get_plugin_directory ()
28
28
print ("Installed plugins:" )
29
29
for plugin in plugin_list :
30
- plugin_version = get_plugin_version (plugin_directory / plugin )
30
+ plugin_version = get_plugin_version (plugin_directory / plugin )
31
31
print (f"{ plugin } :{ plugin_version } " )
Original file line number Diff line number Diff line change 21
21
import tempfile
22
22
import zipfile
23
23
24
-
25
24
from openplugin .utils .local_plugin_utils import check_local_plugin
26
- from openplugin .utils .util import get_plugin_directory , make_zip_file ,get_plugin_version
25
+ from openplugin .utils .util import (
26
+ get_plugin_directory ,
27
+ get_plugin_version ,
28
+ make_zip_file ,
29
+ )
27
30
28
31
29
32
def install_local_plugin () -> bool :
Original file line number Diff line number Diff line change 16
16
17
17
""""""
18
18
import io
19
-
20
19
import zipfile
20
+
21
21
import requests
22
22
23
23
from openplugin .utils .util import (
24
24
get_plugin_directory ,
25
25
get_plugin_list ,
26
- get_zip_file_url ,
27
26
get_plugin_version ,
27
+ get_zip_file_url ,
28
28
)
29
29
30
- def remote_install (plugin_name : str )-> bool :
30
+
31
+ def remote_install (plugin_name : str ) -> bool :
31
32
plugin_list = get_plugin_list ()
32
33
if plugin_name in plugin_list :
33
34
print ("Plugin {} already installed!" .format (plugin_name ))
@@ -47,5 +48,5 @@ def remote_install(plugin_name: str)-> bool:
47
48
plugin_version = get_plugin_version (plugin_directory / plugin_name )
48
49
except :
49
50
raise ValueError ("plugin {} not found" .format (plugin_name ))
50
- print ("Installed plugin: {}:{}!" .format (plugin_name ,plugin_version ))
51
- return True
51
+ print ("Installed plugin: {}:{}!" .format (plugin_name , plugin_version ))
52
+ return True
Original file line number Diff line number Diff line change 24
24
get_plugin_version ,
25
25
)
26
26
27
+
27
28
def uninstall_plugin (plugin_name : str ) -> bool :
28
29
plugin_list = get_plugin_list ()
29
30
if plugin_name not in plugin_list :
@@ -34,4 +35,4 @@ def uninstall_plugin(plugin_name: str) -> bool:
34
35
plugin_version = get_plugin_version (plugin_path )
35
36
if plugin_path .exists () and plugin_path .is_dir ():
36
37
shutil .rmtree (plugin_path )
37
- print ("Uninstalled plugin: {}:{}!" .format (plugin_name ,plugin_version ))
38
+ print ("Uninstalled plugin: {}:{}!" .format (plugin_name , plugin_version ))
Original file line number Diff line number Diff line change 19
19
import shutil
20
20
import tempfile
21
21
import zipfile
22
-
23
22
from pathlib import Path
24
23
25
24
from openplugin .utils .local_plugin_utils import check_local_plugin
26
-
27
25
from openplugin .utils .util import (
28
- get_plugin_list ,
29
26
get_plugin_directory ,
30
- get_plugin_version ,
31
-
27
+ get_plugin_list ,
28
+ get_plugin_version ,
32
29
)
33
30
31
+
34
32
def install_zip_plugin (plugin_zip_file_path : str ) -> bool :
35
33
assert plugin_zip_file_path .endswith (".zip" )
36
34
37
35
tempdir = tempfile .mkdtemp ()
38
36
z = zipfile .ZipFile (plugin_zip_file_path )
39
37
z .extractall (tempdir )
40
38
41
-
42
39
plugin_name = check_local_plugin (Path (tempdir ).iterdir ().__next__ ())
43
40
shutil .rmtree (tempdir , ignore_errors = True )
44
41
plugin_list = get_plugin_list ()
@@ -56,6 +53,5 @@ def install_zip_plugin(plugin_zip_file_path: str) -> bool:
56
53
except :
57
54
raise ValueError ("Install {} failed" .format (plugin_name ))
58
55
59
-
60
- print ("Installed plugin: {}:{}!" .format (plugin_name ,plugin_version ))
61
- return True
56
+ print ("Installed plugin: {}:{}!" .format (plugin_name , plugin_version ))
57
+ return True
Original file line number Diff line number Diff line change 19
19
from pathlib import Path
20
20
21
21
22
- def check_local_plugin (plugin_path :str = "./" ) -> str :
23
- info_file = Path (plugin_path )/ "info.json"
22
+ def check_local_plugin (plugin_path : str = "./" ) -> str :
23
+ info_file = Path (plugin_path ) / "info.json"
24
24
25
25
assert info_file .exists (), "info.json not found"
26
26
info_dict = json .load (open (info_file , "r" ))
Original file line number Diff line number Diff line change 15
15
# limitations under the License.
16
16
17
17
""""""
18
+ import json
18
19
import os
19
20
import platform
20
21
import re
21
22
import shutil
22
23
from pathlib import Path
23
- from typing import Dict ,Union
24
+ from typing import Dict , Union
24
25
25
- import json
26
26
import numpy as np
27
27
28
28
import openplugin
@@ -47,15 +47,18 @@ def get_plugin_list():
47
47
plugin_list .append (plugin .name )
48
48
return plugin_list
49
49
50
- def get_plugin_version (plugin_path : Union [Path ,str ]) -> str :
50
+
51
+ def get_plugin_version (plugin_path : Union [Path , str ]) -> str :
51
52
if isinstance (plugin_path , str ):
52
53
plugin_path = Path (plugin_path )
53
- info_file = plugin_path / "info.json"
54
+ info_file = plugin_path / "info.json"
54
55
assert info_file .exists (), "Plugin info file not found!"
55
56
56
57
with open (info_file ) as f :
57
58
info = json .load (f )
58
59
return info ["version" ]
60
+
61
+
59
62
def make_zip_file (dir_to_put_file_in , plugin_directory , plugin_name ):
60
63
# create a zip file
61
64
zip_file_name = plugin_name
You can’t perform that action at this time.
0 commit comments