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

Renames problem to slug, fixes pexpect hanging-related bugs #131

Merged
merged 7 commits into from
Aug 24, 2017
Merged

Conversation

dmalan
Copy link
Member

@dmalan dmalan commented Aug 4, 2017

In writing up docs, I realized that "problem" doesn't quite work for quizzes, tests, projects, etc. Also fixes #130.

@dmalan dmalan added this to the 2.4.2 milestone Aug 4, 2017
@dmalan dmalan requested review from cmlsharp and brianyu28 August 4, 2017 02:40
brianyu28
brianyu28 previously approved these changes Aug 4, 2017
@@ -139,18 +140,15 @@ def authenticate(org):
pass
authenticate.SOCKET = os.path.join(cache, ORG)

spawn = pexpect.spawn if sys.version_info < (3, 0) else pexpect.spawnu
Copy link
Member Author

Choose a reason for hiding this comment

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

Not needed if not logging to stdout it seems? http://pexpect.readthedocs.io/en/stable/api/pexpect.html#spawn-class

Copy link
Contributor

@cmlsharp cmlsharp Aug 6, 2017

Choose a reason for hiding this comment

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

Per this section, if spawn is used in python3, the arguments to expect are expected to be bytestrings as well. When run under python3 with credentials cached I get TypeError: cannot use a string pattern on a bytes-like object

EDIT: Actually, I was wrong about the cause of the issue. expect can take unicode strings even bytes mode for compatibility reasons. The real issue (as I should have gathered from the text of the error) is that the regex we are using is a string and we are trying to match the bytestring returned by pexpect. Conditionally using spawnu fixes this, but so too would adding a b before the regex EDIT2: making the regex a bytestring doesn't work either since then password is a bytestring which is a problem since we use spawnu in run on python3.


if child.expect(["Username:", pexpect.EOF]):
# Credentials are already cached
if child.expect(["Username:", "Password:", pexpect.EOF]) == 2:
Copy link
Member Author

Choose a reason for hiding this comment

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

Password: can happen if username is configured in .gitconfig.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!

run("git credential-osxkeychain erase", lines=["host=github.com", "protocol=https", ""])
except Error:
pass
if platform.system() == "Darwin":
Copy link
Member Author

Choose a reason for hiding this comment

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

Else error shows up on non-Macs in -v mode.

res = child.expect(["Password for '.*': ", pexpect.EOF])
if res == 0:
i = child.expect(["Password for '.*': ", pexpect.EOF])
if i == 0:
Copy link
Member Author

Choose a reason for hiding this comment

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

Consistency. Also more clear an index.


if child.expect(["Username:", pexpect.EOF]):
# Credentials are already cached
if child.expect(["Username:", "Password:", pexpect.EOF]) == 2:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch!

@@ -139,18 +140,15 @@ def authenticate(org):
pass
authenticate.SOCKET = os.path.join(cache, ORG)

spawn = pexpect.spawn if sys.version_info < (3, 0) else pexpect.spawnu
Copy link
Contributor

@cmlsharp cmlsharp Aug 6, 2017

Choose a reason for hiding this comment

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

Per this section, if spawn is used in python3, the arguments to expect are expected to be bytestrings as well. When run under python3 with credentials cached I get TypeError: cannot use a string pattern on a bytes-like object

EDIT: Actually, I was wrong about the cause of the issue. expect can take unicode strings even bytes mode for compatibility reasons. The real issue (as I should have gathered from the text of the error) is that the regex we are using is a string and we are trying to match the bytestring returned by pexpect. Conditionally using spawnu fixes this, but so too would adding a b before the regex EDIT2: making the regex a bytestring doesn't work either since then password is a bytestring which is a problem since we use spawnu in run on python3.

@kzidane kzidane merged commit f06f7a4 into develop Aug 24, 2017
@kzidane kzidane deleted the slug branch August 24, 2017 20:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hangs when credential.https://github.com/submit50.username is set but password is not in ssh-agent
4 participants