<p>I use the following two functions:</p>
<div class="highlight highlight-python"><pre><span class="pl-k">import</span> keyring
<span class="pl-k">def</span> <span class="pl-en">get_password</span>(<span class="pl-smi">server</span>, <span class="pl-smi">username</span>):
<span class="pl-k">return</span> keyring.get_password(server, username)
<span class="pl-k">def</span> <span class="pl-en">set_password</span>(<span class="pl-smi">server</span>, <span class="pl-smi">username</span>, <span class="pl-smi">password</span>):
keyring.set_password(server, username, password)</pre></div>
<p>Problem: setting the passwords is a manual act, offlineimap doesn’t use the set_password to save the password it queries.</p>
<p>I tried the following:</p>
<div class="highlight highlight-python"><pre><span class="pl-k">import</span> keyring
<span class="pl-k">import</span> getpass
<span class="pl-k">def</span> <span class="pl-en">get_password</span>(<span class="pl-smi">server</span>, <span class="pl-smi">username</span>):
pw <span class="pl-k">=</span> keyring.get_password(server, username)
<span class="pl-k">if</span> <span class="pl-k">not</span> pw:
pw <span class="pl-k">=</span> getpass.getpass(<span class="pl-s"><span class="pl-pds">"</span>Password: <span class="pl-pds">"</span></span>)
set_password(server, username, password)
<span class="pl-k">return</span> pw</pre></div>
<p>but offlineimap’s multithreadedness screws that up (try it!).</p>
<p>What do?</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/OfflineIMAP/offlineimap/issues/218">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AKFSEO0xQHMjXwoOg_VYJrDXTA_UAeYKks5oe-qLgaJpZM4FbkAB.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/OfflineIMAP/offlineimap/issues/218"></link>
<meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>