Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Introduce CliBase
  • Loading branch information
rozhkovdmitrii committed Feb 3, 2022
commit 35902959c2e3921c591efbd97d4aa89a14cc11e7
26 changes: 15 additions & 11 deletions proxy/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,27 @@
GET_WHITE_LIST_BALANCE_MAX_RETRIES = int(os.environ.get("GET_WHITE_LIST_BALANCE_MAX_RETRIES", 3))
GET_WHITE_LIST_BALANCE_RETRY_INTERVAL_S = int(os.environ.get("GET_WHITE_LIST_BALANCE_RETRY_INTERVAL_S", 1))


class CliBase:

def run_cli(self, cmd: List[str]) -> str:
self.debug("Calling: " + " ".join(cmd))
proc_result = subprocess.run(cmd, timeout=neon_cli_timeout, universal_newlines=True, stdout=subprocess.PIPE,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neon_cli_timeout should only be used for neon-cli

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Vasilii!
Fixed here and in the other place

stderr=subprocess.PIPE)
if proc_result.stderr:
print(proc_result.stderr, file=sys.stderr)
return proc_result.stdout


@logged_group("neon.Proxy")
class solana_cli:
class solana_cli(CliBase):
def call(self, *args):
try:
cmd = ["solana",
"--url", SOLANA_URL,
] + list(args)
self.debug("Calling: " + " ".join(cmd))
return subprocess.check_output(cmd, universal_newlines=True)
return self.run_cli(cmd)
except subprocess.CalledProcessError as err:
self.error("ERR: solana error {}".format(err))
raise
Expand Down Expand Up @@ -102,15 +114,7 @@ def read_sol_account(name) -> Optional[SolanaAccount]:


@logged_group("neon.Proxy")
class neon_cli:

def run_cli(self, cmd: List[str]) -> str:
self.debug("Calling: " + " ".join(cmd))
proc_result = subprocess.run(cmd, timeout=neon_cli_timeout, universal_newlines=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
if proc_result.stderr:
print(proc_result.stderr, file=sys.stderr)
return proc_result.stdout
class neon_cli(CliBase):

def call(self, *args):
try:
Expand Down