def __init__(self): super(HerringSettings, self).__init__('Herring', 'herring', ['Herring'], self.HELP) self._herringlib_path = ['herringlib'] if 'HERRINGLIB' in os.environ: self._herringlib_path.append(os.environ['HERRINGLIB']) self._herringlib_path.append('~/.herring/herringlib') herring_conf = os.path.expanduser('~/.herring/herring.conf') if not os.path.isfile(herring_conf): herring_conf_dir = os.path.dirname(herring_conf) try: if not os.path.isdir(herring_conf_dir): os.makedirs(herring_conf_dir) except (IOError, OSError): pass user = '******' if 'USER' in os.environ: user = os.environ['USER'] email = '{user}@localhost'.format(user=user) try: with open(herring_conf, 'w', encoding="utf-8") as conf_file: conf_file.write(textwrap.dedent(u"""\ [Herring] [project] author: {author} author_email: {email} dist_host: localhost pypi_path: /var/pypi/dev """.format(author=user, email=email))) except IOError as ex: warning("Could not create ~/.herring/herring.conf ({file}) - {err}".format(file=herring_conf, err=str(ex)))
def _create_herring_conf_file(self, herring_conf): herring_conf_dir = os.path.dirname(herring_conf) mkdir_p(herring_conf_dir) user = os.getenv('USER', 'nobody') email = '{user}@localhost'.format(user=user) try: with io.open(herring_conf, 'w', encoding="utf-8") as conf_file: conf_file.write(textwrap.dedent(u"""\ [Herring] [project] author: {author} author_email: {email} dist_host: localhost pypi_path: /var/pypi/dev """.format(author=user, email=email))) except IOError as ex: warning("Could not create ~/.herring/herring.conf ({file}) - {err}".format(file=herring_conf, err=str(ex)))