Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(p4): add disconnect before any connect #474

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Changes from all commits
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
26 changes: 12 additions & 14 deletions universum/modules/vcs/perforce_vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,26 @@ def __init__(self, *args, **kwargs):
@make_block("Connecting")
@catch_p4exception()
def connect(self):
if not self.p4.connected():
self.p4.port = self.settings.port
self.p4.user = self.settings.user
self.p4.password = self.settings.password
self.disconnect()
self.p4.port = self.settings.port
self.p4.user = self.settings.user
self.p4.password = self.settings.password

self.p4.connect()
self.append_repo_status("Perforce server: " + self.settings.port + "\n\n")
self.p4.connect()
self.append_repo_status("Perforce server: " + self.settings.port + "\n\n")

@make_block("Disconnecting")
def disconnect(self):
with warnings.catch_warnings(record=True) as w:
self.p4.disconnect()
if not w:
return
if "Not connected" in str(w[0].message):
text = "Perforce client is not connected on disconnect. Something must have gone wrong"
self.structure.fail_current_block(text)
else:
text = ""
for line in w:
text += "\n" + warnings.formatwarning(line.message, line.category, line.filename, line.lineno)
self.structure.fail_current_block("Unexpected warning(s): " + text)
if "Not connected" in str(w[0].message): # We consider it ok for a session to expire or not be created yet
return
text = ""
for line in w:
text += "\n" + warnings.formatwarning(line.message, line.category, line.filename, line.lineno)
self.structure.fail_current_block("Unexpected warning(s): " + text)
raise SilentAbortException()

def finalize(self):
Expand Down