Closed vpeopleonatank closed 3 years ago
could you try the command below?
pcm ppp https://codeforces.com/contest/1523/problem/F
By reading through the error, it seems that the error is not from 'pcm ss' but from 'pcm ppp'.
At least, in my environment, both pcm ppp and pcm ss works fine.
pcm ppp and pcm pp works for me, only pcm ss has problem. What is your nodejs version? Mine is 15.5.0
my node version is v8.10.0
can you reproduce this error? I guess that this was a one-time error.
And also happen for other problems?
I think your error happened because the part below failed at that time due to a network error or something.
try:
problem_data = problem.download_data()
problem_title = problem_data.name
note that this part is in the function below.
def ppp(config: Config, task_url: str, current_dir: bool, prob_name: str, force: bool, execute_hook: bool) -> None:
if current_dir:
config.pref['problem_root_dir'] = '.'
work_dir = _prepare_problem(config, task_url, prob_name, force)
# execute custom_hook_command
if not execute_hook: return
try:
cstr = config.pref['ppp']['custom_hook_command']['after'].format(dirname=work_dir.resolve())
print(cstr)
subprocess.run(cstr, shell=True)
except Exception as e:
if config.verbose:
print(e)
def _prepare_problem(config: Config, task_url: str, prob_name: str = '', force: bool = False, from_pp: bool = False) -> Path:
problem_dir: Path
problem_title: str
if task_url != '':
problem: Problem = cast(Problem, onlinejudge.dispatch.problem_from_url(task_url))
assert problem != None
problem_dir = get_work_directory(config, problem, from_pp=from_pp)
try:
problem_data = problem.download_data()
problem_title = problem_data.name
except:
pass
else:
problem_dir = Path('./prob').resolve()
if prob_name:
problem_dir = problem_dir.parent / prob_name
if Path(problem_dir).exists():
if force:
shutil.rmtree(problem_dir)
else:
print(f'{problem_dir} directory already exists')
return problem_dir
problem_dir.parent.mkdir(parents=True, exist_ok=True)
shutil.copytree(config.pref['template_dir'], f'{problem_dir}/')
# download sample cases
if task_url:
_download_sample(task_url, problem_dir)
if problem_title:
with open(problem_dir / problem_title, "w"):
pass
return problem_dir
anyway, I should modify to initialize 'problem_title' at first.
can you reproduce this error? I guess that this was a one-time error. And also happen for other problems?
This error often happens when I use pcm ss
. pcm pp
and pcm ppp
always work without error
pcm ss
internally call pcm ppp
, and your error message indicates that pcm ppp
failed by "UnboundLocalError".
So I think this is not from your node version as long as pcm ppp
is called.
pcm ppp
is a pure python code and is not depending on nodejs.
As mentioned, "UnboundLocalError" happened because the try section of the __prepare_problem failed. when the try section fails, 'problem title' is not initialized, and in the last part of __prepare_problem the variable is referenced and "UnboundLocalError" happens. So I can fix the error by initializing the variable at first.
def _prepare_problem(config: Config, task_url: str, prob_name: str = '', force: bool = False, from_pp: bool = False) -> Path:
problem_dir: Path
problem_title: str
if task_url != '':
problem: Problem = cast(Problem, onlinejudge.dispatch.problem_from_url(task_url))
assert problem != None
problem_dir = get_work_directory(config, problem, from_pp=from_pp)
try:
problem_data = problem.download_data()
problem_title = problem_data.name
except:
pass
else:
problem_dir = Path('./prob').resolve()
But I don't know why the try section fails only when using pcm ss
in your environment.
Could you try reinstalling via developer-mode? if you can, we can investigate more.
# uninstalling the current version.
pip uninstall pcm
# install for developing
git clone https://github.com/kjnh10/pcm.git
cd pcm
pip install --editable ./
and check out the branch and test pcm ss
and let's see what happens
git checkout investigate-#51
and check out the branch and test
pcm ss
and let's see what happensgit checkout investigate-#51
I get SyntaxError when run pcm ss
sorry, i inserted tiny bug...
could you pull the new commit i have just pushed?
git pull origin investigate-\#51
sorry, i inserted tiny bug... could you pull the new commit i have just pushed?
git pull origin investigate-\#51
When I use pcm ss
now, It sometimes shows error like this
is this because the contest was running and the server was busy?
'sometimes' means pcm ss
succeeded sometimes?
Contest which I fetch was over. pcm ss
sometimes runs without error.
I meant that when you fetch, another contest was running and the codeforce's server was busy.
Anyway, for the 503 Server error, I don't have anything to do. But by the fix I did, even though 503 server error for getting problem title, preparing problem directory became to succeed.
I will include this fix in the next release which will be in a week.
Is this enough for you?
That 's enough for me. Thanks for your work.
v0.8.1 has been released, which includes this fix.
if you still have an issue with v0.8.1, please reopen this issue.
I use
pcm ss
to listen for Competitive Companion(CC) (example contest https://codeforces.com/contest/1523) , but error show as tittle when pcm parse from CC.This is full error message from cli
``` stderr: node:child_process:333 ex = new Error('Command failed: ' + cmd + '\n' + stderr); ^ Error: Command failed: pwd && pcm ppp https://codeforces.com/contest/1523/problem/F Traceback (most recent call last): File "/home/vpoat/.local/bin/pcm", line 11, in