From 2dca6b4bc67989acf4ad9179b8d83a00d1a50380 Mon Sep 17 00:00:00 2001 From: Nondzu Date: Thu, 2 Jun 2022 10:58:03 +0200 Subject: [PATCH] cleanup & readme update --- README.md | 32 ++++++++++++++++++++++++++++++++ better-call-reward.py | 33 ++++++++++++--------------------- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 7312aa2..0d9a759 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,34 @@ # better-call-reward Script calling 'reward' for Livepeer orchestrator + + + +usage: better-call-reward.py [-h] [-url [URL]] [-delay [DELAY]] + +Optional app description + +optional arguments: + -h, --help show this help message and exit + -url [URL] URL for your Orchestrator + -delay [DELAY] delay between next try of call "reward" + +example usage: +./better-call-reward.py -url http://localhost:7935 +or use + +some error: +Orchestrator URL: http://192.168.137.103:7935 +Connection success +---Info--- +Orchestrator Version: 0.5.31-ec920c67 +GolangRuntimeVersion: go1.18.1 + +Transcoders: +[1] Address: 127.0.0.1:54396 Capacity:14 + +[ 2022-06-02 10:33:26.291112 ] Orchestrator status: online +[ 2022-06-02 10:33:26.291156 ] Last reward round: 2584 +[ 2022-06-02 10:33:26.291175 ] Current round: 2585 +[ 2022-06-02 10:33:26.291189 ] Call reward! +[ 2022-06-02 10:33:26.292445 ] +[ 2022-06-02 10:33:26.292469 ] Call reward fail. Error: \ No newline at end of file diff --git a/better-call-reward.py b/better-call-reward.py index 377ce30..ceb78e5 100755 --- a/better-call-reward.py +++ b/better-call-reward.py @@ -2,34 +2,27 @@ from asyncio import constants from pyclbr import Function import requests -import json import time import sys import argparse from datetime import datetime -import logging # set your Orchestrator url -# orchUrl = 'http://192.168.137.103:7935' URL_DEFAULT = 'http://localhost:7935' # default -waitTime = 60 * 60 # check reward every 1 hour (value in second) -waitTime = 15 -retryTimeOffline = 60 # delay when O is offline in second -retryTimeReward = 60 * 60 # time for check and call reward in second - - -def my_function(): - print("Hello from a function") +retryTimeOffline = 60 # delay when O is offline, in seconds +retryTimeReward = 60 * 60 # time retry call "reward ", in seconds def parseArgs(): # Instantiate the parser - parser = argparse.ArgumentParser(description='Optional app description') + parser = argparse.ArgumentParser( + description='Script to resolve problem with livepeer "reward" call. ') parser.add_argument('-url', type=str, nargs='?', help='URL for your Orchestrator') - parser.add_argument('-delay', type=int, nargs='?', - help='delay between next try of call "reward"') + # todo: ? add delay params + # parser.add_argument('-delay', type=int, nargs='?', + # help='delay between next try of call "reward"') # Parse the argument args = parser.parse_args() if args.url is None: @@ -40,10 +33,8 @@ def parseArgs(): return url # end parseArgs() -# check O status and get some info - -def statusOrch(url): # /status +def statusOrch(url): # /status , check O status and get some info try: r = requests.get(url + '/status') responseStatus = r.status_code @@ -53,7 +44,7 @@ def statusOrch(url): # /status exit(0) print("Connection success") print("---Info---") - print("Version: " + r.json()['Version']) + print("Orchestrator Version: " + r.json()['Version']) print("GolangRuntimeVersion: " + r.json()['GolangRuntimeVersion']) print("") @@ -131,12 +122,12 @@ while True: if currentRound != lastRewardRound: log('Call reward!') - r = requests.get(url + '/rewardss') # call reward + r = requests.get(url + '/reward') # call reward log(r) if r.status_code == 200: - log('Call reward success.') + log('Call to reward success.') else: - log('Call reward fail. Error: ' + str(r)) + log('Call to reward fail. Error: ' + str(r)) else: log('Do not call reward. ' + 'Reward for current round ' +