22import os
33import subprocess
44
5- import pkg_resources
6-
75from modules .module import MtcModule
86from mypylib .mypylib import run_as_root , color_print , bcolors , print_table
7+ from mytoncore .utils import get_package_resource_path
98from mytonctrl .utils import get_current_user
109
1110
@@ -59,20 +58,20 @@ def create_env_file(self, reinit=False):
5958
6059 def add_daemon (self , user : str = None ):
6160 start = f'{ self .bin_dir } /oracle'
62- script_path = pkg_resources .resource_filename ('mytoninstaller' , 'scripts/add2systemd.sh' )
6361 if user is None :
6462 user = get_current_user ()
65- run_as_root (['bash' , script_path , '-n' , 'btc_teleport' , '-u' , user , '-g' , user , '-s' , start , '-w' , self .bin_dir ])
63+ with get_package_resource_path ('mytoninstaller' , 'scripts/add2systemd.sh' ) as script_path :
64+ run_as_root (['bash' , script_path , '-n' , 'btc_teleport' , '-u' , user , '-g' , user , '-s' , start , '-w' , self .bin_dir ])
6665
6766 def install (self , branch : str , user : str = None ):
68- script_path = pkg_resources .resource_filename ('mytonctrl' , 'scripts/btc_teleport1.sh' )
6967 if user is None :
7068 user = get_current_user ()
71- exit_code = run_as_root (["bash" , script_path , "-s" , '/usr/src' , "-r" , self .repo_name , "-b" , branch , "-u" , user ])
69+ with get_package_resource_path ('mytonctrl' , 'scripts/btc_teleport1.sh' ) as script_path :
70+ exit_code = run_as_root (["bash" , script_path , "-s" , '/usr/src' , "-r" , self .repo_name , "-b" , branch , "-u" , user ])
7271 if exit_code != 0 :
7372 raise Exception ('Failed to install btc_teleport' )
74- script_path = pkg_resources . resource_filename ('mytonctrl' , 'scripts/btc_teleport2.sh' )
75- subprocess .run (["bash" , script_path , "-s" , self .src_dir ])
73+ with get_package_resource_path ('mytonctrl' , 'scripts/btc_teleport2.sh' ) as script_path :
74+ subprocess .run (["bash" , script_path , "-s" , self .src_dir ])
7675
7776 def init (self , reinstall = False , branch : str = 'master' , user : str = None ):
7877 if os .path .exists (self .src_dir ) and not reinstall :
@@ -89,8 +88,8 @@ def init(self, reinstall=False, branch: str = 'master', user: str = None):
8988
9089 @staticmethod
9190 def run_remove_btc_teleport (args ):
92- script_path = pkg_resources . resource_filename ('mytonctrl' , 'scripts/remove_btc_teleport.sh' )
93- return run_as_root (["bash" , script_path ] + args )
91+ with get_package_resource_path ('mytonctrl' , 'scripts/remove_btc_teleport.sh' ) as script_path :
92+ return run_as_root (["bash" , script_path ] + args )
9493
9594 def get_save_offers (self ):
9695 bname = "saveOffersBtcTeleport"
@@ -233,5 +232,3 @@ def remove_btc_teleport(self, args: list):
233232
234233 def add_console_commands (self , console ):
235234 console .AddItem ("remove_btc_teleport" , self .remove_btc_teleport , self .local .translate ("remove_btc_teleport_cmd" ))
236- console .AddItem ("vote_offer_btc_teleport" , self .vote_offer_btc_teleport , self .local .translate ("vote_offer_btc_teleport_cmd" ))
237- console .AddItem ("print_offers_btc_teleport_list" , self .print_offers_btc_teleport_list , self .local .translate ("print_offers_btc_teleport_list_cmd" ))
0 commit comments