File: ext-get-password-from-env.py

package info (click to toggle)
hg-git 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,244 kB
  • sloc: python: 8,702; sh: 185; makefile: 23
file content (21 lines) | stat: -rw-r--r-- 411 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# small dummy extension that obtains passwords from an environment
# variable
#

import getpass
import os
import sys


def newgetpass(args):
    try:
      passwd = os.environb.get(b'PASSWD', b'nope')
      print(passwd.encode())
    except AttributeError: # python 2.7
      passwd = os.environ.get('PASSWD', 'nope')
      print(passwd)
    sys.stdout.flush()
    return passwd

getpass.getpass = newgetpass