summaryrefslogtreecommitdiff
path: root/900-implements.yarn
diff options
context:
space:
mode:
Diffstat (limited to '900-implements.yarn')
-rw-r--r--900-implements.yarn41
1 files changed, 24 insertions, 17 deletions
diff --git a/900-implements.yarn b/900-implements.yarn
index 9a2493f..da6d961 100644
--- a/900-implements.yarn
+++ b/900-implements.yarn
@@ -5,16 +5,16 @@
IMPLEMENTS GIVEN server is also known as (\S+)
import yarnhelper
h = yarnhelper.YarnHelper()
- h.set_variable('SERVER', h.get_next_match())
+ h.set_variable('ALIAS', h.get_next_match())
## HTTP requests
IMPLEMENTS WHEN user fetches (\S+)
- import yarnhelper
+ import os, yarnhelper
h = yarnhelper.YarnHelper()
- server = h.get_variable('SERVER')
+ address = os.environ['ADDRESS']
url = h.get_next_match()
- status, body = h.http_get(server, url)
+ status, body = h.http_get(address, url)
h.set_variable('http_status', status)
h.set_variable('http_body', body)
@@ -38,9 +38,9 @@
IMPLEMENTS WHEN user runs Gitano (.*)
import os, re, cliapp, yarnhelper
h = yarnhelper.YarnHelper()
- server = os.environ['SERVER']
+ address = os.environ['ADDRESS']
cmd = h.get_next_match()
- argv = ['ssh', 'git@' + server] + cmd.split()
+ argv = ['ssh', 'git@' + address] + cmd.split()
exit, out, err = cliapp.runcmd_unchecked(argv)
h.set_variable('argv', argv)
h.set_variable('exit', int(exit))
@@ -50,9 +50,9 @@
IMPLEMENTS WHEN user clones the (\S+) repository over git://
import os, re, cliapp, yarnhelper
h = yarnhelper.YarnHelper()
- server = os.environ['SERVER']
+ address = os.environ['ADDRESS']
repo = h.get_next_match()
- url = 'git://{}/{}'.format(server, repo)
+ url = 'git://{}/{}'.format(address, repo)
argv = ['git', 'clone', url]
exit, out, err = cliapp.runcmd_unchecked(argv, cwd=os.environ['DATADIR'])
h.set_variable('argv', argv)
@@ -105,15 +105,16 @@
## Send mail over SMTP+TLS
IMPLEMENTS WHEN someone sends mail to (\S+) with subject \$(\S+)
- import smtplib, sys, yarnhelper
+ import os, smtplib, sys, yarnhelper
h = yarnhelper.YarnHelper()
to_addr = h.get_next_match()
subject_key = h.get_next_match()
- server_name = h.get_variable('SERVER')
+ subject = h.get_variable(subject_key)
+ address = os.environ['ADDRESS']
from_addr = 'someone@example.com'
msg = 'From: {}\nTo: {}\nSubject: {}\n\nThis is the body\n'.format(
from_addr, to_addr, subject)
- server = smtplib.SMTP(server_name)
+ server = smtplib.SMTP(address)
server.set_debuglevel(True)
server.starttls()
server.sendmail(from_addr, to_addr, msg)
@@ -122,16 +123,21 @@
## Check for a mail in a mailbox
IMPLEMENTS THEN mailbox of (\S+) has a mail with subject \$(\S+)
- import email, imaplib, subprocess, yarnhelper
+ import email, imaplib, os, subprocess, yarnhelper
h = yarnhelper.YarnHelper()
user = h.get_next_match()
- subject = h.get_next_match()
- server = h.get_variable('SERVER')
- pass_name = 'server-yarns/imap/{}@{}'.format(user, server)
- p = subprocess.Popen(['pass', 'show', pass_name], stdout=subprocess.PIPE)
+ subject_key = h.get_next_match()
+ subject = h.get_variable(subject_key)
+ print 'Wanted:', subject
+ address = os.environ['ADDRESS']
+ pass_name = 'server-yarns/imap/{}@{}'.format(user, address)
+ pass_home = os.environ['PASS_HOME']
+ p = subprocess.Popen(
+ ['env', 'HOME={}'.format(pass_home), 'pass', 'show', pass_name],
+ stdout=subprocess.PIPE)
stdout, stderr = p.communicate()
password = stdout.rstrip()
- m = imaplib.IMAP4_SSL(server)
+ m = imaplib.IMAP4_SSL(address)
m.login(user, password)
m.select('INBOX', True)
typ, data = m.search(None, 'ALL')
@@ -140,6 +146,7 @@
typ, data = m.fetch(num, '(RFC822)')
typ, text = data[0]
msg = email.message_from_string(text)
+ print 'Subject:', msg['Subject']
got_it = got_it or (msg['Subject'] == subject)
m.close()
m.logout()