Skip to content

Commit

Permalink
Merge pull request #197 from ZhouBox/v2.8
Browse files Browse the repository at this point in the history
[v2.8]update default plugins
  • Loading branch information
fengzeroz authored Jun 6, 2024
2 parents eaadf05 + 0af6d65 commit af70769
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cross-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ case $cnc in
$neuron_modules_dir/build/plugins/libplugin-mitsubishi_cnc.so \
$neuron_modules_dir/build/plugins/libplugin-heidenhain_cnc.so \
$package_dir/plugins/;

python3 update_default_plugins.py $package_dir/config/default_plugins.json "libplugin-focas.so,libplugin-mitsubishi_cnc.so,libplugin-heidenhain_cnc.so";
cp $neuron_modules_dir/build/plugins/focas/libfocas32.so.1 $package_dir/;;
(false)
echo "no cnc";;
Expand All @@ -163,7 +163,8 @@ case $custom in
(cun)
cp $neuron_modules_dir/build/plugins/libplugin-gewu2.so \
$neuron_modules_dir/build/plugins/libplugin-s7comm-for-un.so \
$package_dir/plugins/;;
$package_dir/plugins/;
python3 update_default_plugins.py $package_dir/config/default_plugins.json "libplugin-gewu2.so,libplugin-s7comm-for-un.so";;
(default)
echo "no custom";;
esac
Expand Down
38 changes: 38 additions & 0 deletions update_default_plugins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sys
import json


def update(file_path, plugins_str):
with open(file_path, 'r') as file:
data = file.read()

try:
json_data = json.loads(data)
except json.JSONDecodeError as e:
print(f"Error parsing JSON file: {e}")
sys.exit(1)

if 'plugins' not in json_data:
print(f"Error no plugins array:")
sys.exit(1)

plugins = plugins_str.split(',')
for plugin in plugins:
if plugin not in json_data['plugins']:
json_data['plugins'].append(plugin)

with open(file_path, 'w') as file:
json.dump(json_data, file, indent=4)

print(f"Plugins have been added to {file_path}")


if __name__ == '__main__':
if len(sys.argv) != 3:
print("Usage: python script.py file_path plugins_str")
sys.exit(1)

file_path = sys.argv[1]
plugins_str = sys.argv[2]

update(file_path, plugins_str)

0 comments on commit af70769

Please sign in to comment.