** Description changed:

+ [Impact]
+ Invoking ssh-import-id gh:$missing_user in a non-interactive context produces 
no output.
+ 
+ [Test case]
+ "ssh-import-id gh:mwhudso 2>&1 | cat" should output "no such user" or some 
similar helpful messsage, not nothing at all.
+ 
+ [Regression potential]
+ The upload to bionic unapproved is an untested combination of patches so 
needs careful testing. Fortunately each patch is small and mostly independent 
so testing each affected area of code should not be too onerous.
+ 
+ [Original Description]
  mwhudson@ringil:~/src/ssh-import-id$ ssh-import-id gh:mwhudso
  Username "mwhudso" not found at GitHub API
  mwhudson@ringil:~/src/ssh-import-id$ ssh-import-id gh:mwhudso | cat
- mwhudson@ringil:~/src/ssh-import-id$ 
+ mwhudson@ringil:~/src/ssh-import-id$
  
  What happened? The offending code looks like
  
-               if resp.status_code == 404:
-                       print('Username "%s" not found at GitHub API' % ghid)
-                       os._exit(1)
+   if resp.status_code == 404:
+    print('Username "%s" not found at GitHub API' % ghid)
+    os._exit(1)
  
  print does not flush by default. When stdout is a terminal you get an
  implicit flush on newline but when it's a pipe you do not and calling
  _exit(1) exits the process without flushing the buffers either. Two
  fixes suggest themselves: 1) add flush=True to the print() calls 2)
  exiting more conventionally by e.g. calling sys.exit()

** Description changed:

  [Impact]
  Invoking ssh-import-id gh:$missing_user in a non-interactive context produces 
no output.
+ 
+ I want to change subiquity to invoke ssh-import-id directly and helpful
+ error messages are important in giving useful feedback to the user.
  
  [Test case]
  "ssh-import-id gh:mwhudso 2>&1 | cat" should output "no such user" or some 
similar helpful messsage, not nothing at all.
  
  [Regression potential]
  The upload to bionic unapproved is an untested combination of patches so 
needs careful testing. Fortunately each patch is small and mostly independent 
so testing each affected area of code should not be too onerous.
  
  [Original Description]
  mwhudson@ringil:~/src/ssh-import-id$ ssh-import-id gh:mwhudso
  Username "mwhudso" not found at GitHub API
  mwhudson@ringil:~/src/ssh-import-id$ ssh-import-id gh:mwhudso | cat
  mwhudson@ringil:~/src/ssh-import-id$
  
  What happened? The offending code looks like
  
    if resp.status_code == 404:
     print('Username "%s" not found at GitHub API' % ghid)
     os._exit(1)
  
  print does not flush by default. When stdout is a terminal you get an
  implicit flush on newline but when it's a pipe you do not and calling
  _exit(1) exits the process without flushing the buffers either. Two
  fixes suggest themselves: 1) add flush=True to the print() calls 2)
  exiting more conventionally by e.g. calling sys.exit()

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1770302

Title:
  ssh-import-id gh:$missing-user does not flush stdout properly

To manage notifications about this bug go to:
https://bugs.launchpad.net/ssh-import-id/+bug/1770302/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to