Skip to content

Commit e6f319f

Browse files
Merge pull request #397 from mishaschwartz/v2.2.1
v2.2.1
2 parents 7ac38d2 + 44d5ac2 commit e6f319f

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

Changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# CHANGELOG
22
All notable changes to this project will be documented here.
33

4+
## [v2.2.1]
5+
- Raise error if rq or supervisord executables can't be found when running start_stop.py (#390)
6+
- Bump python-ta version to 2.3.2 (#391)
7+
48
## [v2.2.0]
59
- Support dependencies on specific package versions and non-CRAN sources for R tester (#323)
610
- Testers no longer generate automated content for feedback files (#375)

server/autotest_server/testers/pyta/pyta_tester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def add_annotations(self, data: List[Dict]) -> None:
4949
"filename": result["filename"],
5050
"content": msg["msg"],
5151
"line_start": msg["line"],
52-
"line_end": msg["line_end"],
52+
"line_end": msg["end_line"],
5353
"column_start": msg["column"],
54-
"column_end": msg["column_end"],
54+
"column_end": msg["end_column"],
5555
}
5656
)
5757

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
python-ta==1.4.2;python_version<"3.8"
2-
python-ta==2.1.0; python_version>="3.8"
2+
python-ta==2.3.2; python_version>="3.8"
33
isort<5;python_version<"3.8"

server/start_stop.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
_THIS_DIR = os.path.dirname(os.path.realpath(__file__))
1313
_PID_FILE = os.path.join(_THIS_DIR, "supervisord.pid")
1414
_CONF_FILE = os.path.join(_THIS_DIR, "supervisord.conf")
15-
_SUPERVISORD = os.path.join(os.path.dirname(sys.executable), "supervisord")
16-
_RQ = os.path.join(os.path.dirname(sys.executable), "rq")
15+
_SUPERVISORD = shutil.which(os.path.join(os.path.dirname(sys.executable), "supervisord")) or shutil.which("supervisord")
16+
_RQ = shutil.which(os.path.join(os.path.dirname(sys.executable), "rq")) or shutil.which("rq")
1717

1818
SECONDS_PER_DAY = 86400
1919

@@ -48,13 +48,13 @@ def redis_connection() -> redis.Redis:
4848
return redis.Redis.from_url(config["redis_url"], decode_responses=True)
4949

5050

51-
def create_enqueuer_wrapper():
51+
def create_enqueuer_wrapper(rq):
5252
with open(_CONF_FILE, "w") as f:
5353
f.write(HEADER)
5454
for worker_data in config["workers"]:
5555
c = CONTENT.format(
5656
worker_user=worker_data["user"],
57-
rq=_RQ,
57+
rq=rq,
5858
worker_args=f'--url {config["redis_url"]}',
5959
queues=" ".join(worker_data["queues"]),
6060
numprocs=1,
@@ -63,9 +63,9 @@ def create_enqueuer_wrapper():
6363
f.write(c)
6464

6565

66-
def start(extra_args):
67-
create_enqueuer_wrapper()
68-
subprocess.run([_SUPERVISORD, "-c", _CONF_FILE, *extra_args], check=True, cwd=_THIS_DIR)
66+
def start(rq, supervisord, extra_args):
67+
create_enqueuer_wrapper(rq)
68+
subprocess.run([supervisord, "-c", _CONF_FILE, *extra_args], check=True, cwd=_THIS_DIR)
6969

7070

7171
def stop():
@@ -77,8 +77,8 @@ def stop():
7777
sys.stderr.write("supervisor is already stopped")
7878

7979

80-
def stat(extra_args):
81-
subprocess.run([_RQ, "info", "--url", config["redis_url"], *extra_args], check=True)
80+
def stat(rq, extra_args):
81+
subprocess.run([rq, "info", "--url", config["redis_url"], *extra_args], check=True)
8282

8383

8484
def clean(age, dry_run):
@@ -98,14 +98,21 @@ def clean(age, dry_run):
9898
shutil.rmtree(dir_path)
9999

100100

101+
def _exec_type(path):
102+
exec_path = shutil.which(path)
103+
if exec_path:
104+
return exec_path
105+
raise argparse.ArgumentTypeError(f"no executable found at: '{path}'")
106+
107+
101108
if __name__ == "__main__":
102109
parser = argparse.ArgumentParser()
103110
subparsers = parser.add_subparsers(dest="command")
104111

105-
subparsers.add_parser("start", help="start the autotester")
112+
start_parser = subparsers.add_parser("start", help="start the autotester")
106113
subparsers.add_parser("stop", help="stop the autotester")
107-
subparsers.add_parser("restart", help="restart the autotester")
108-
subparsers.add_parser("stat", help="display current status of the autotester queues")
114+
restart_parser = subparsers.add_parser("restart", help="restart the autotester")
115+
stat_parser = subparsers.add_parser("stat", help="display current status of the autotester queues")
109116
clean_parser = subparsers.add_parser("clean", help="clean up old/unused test scripts")
110117

111118
clean_parser.add_argument(
@@ -115,15 +122,25 @@ def clean(age, dry_run):
115122
"-d", "--dry-run", action="store_true", help="list files that will be deleted without actually removing them"
116123
)
117124

125+
for parser_ in (start_parser, restart_parser, stat_parser):
126+
parser_.add_argument("--rq", default=_RQ, type=_exec_type, help=f"path to rq executable, default={_RQ}")
127+
if parser_ is not stat_parser:
128+
parser_.add_argument(
129+
"--supervisord",
130+
default=_SUPERVISORD,
131+
type=_exec_type,
132+
help=f"path to supervisord executable, default={_SUPERVISORD}",
133+
)
134+
118135
args, remainder = parser.parse_known_args()
119136
if args.command == "start":
120-
start(remainder)
137+
start(args.rq, args.supervisord, remainder)
121138
elif args.command == "stop":
122139
stop()
123140
elif args.command == "restart":
124141
stop()
125-
start(remainder)
142+
start(args.rq, args.supervisord, remainder)
126143
elif args.command == "stat":
127-
stat(remainder)
144+
stat(args.rq, remainder)
128145
elif args.command == "clean":
129146
clean(args.age, args.dry_run)

0 commit comments

Comments
 (0)