How to use sts method in localstack

Best Python code snippet using localstack_python

mboxconvert.py

Source:mboxconvert.py Github

copy

Full Screen

1#! /usr/bin/env python2# Convert MH directories (1 message per file) or MMDF mailboxes (4x^A3# delimited) to unix mailbox (From ... delimited) on stdout.4# If -f is given, files contain one message per file (e.g. MH messages)5import rfc8226import sys7import time8import os9import stat10import getopt11import re12def main():13 dofile = mmdf14 try:15 opts, args = getopt.getopt(sys.argv[1:], 'f')16 except getopt.error, msg:17 sys.stderr.write('%s\n' % msg)18 sys.exit(2)19 for o, a in opts:20 if o == '-f':21 dofile = message22 if not args:23 args = ['-']24 sts = 025 for arg in args:26 if arg == '-' or arg == '':27 sts = dofile(sys.stdin) or sts28 elif os.path.isdir(arg):29 sts = mh(arg) or sts30 elif os.path.isfile(arg):31 try:32 f = open(arg)33 except IOError, msg:34 sys.stderr.write('%s: %s\n' % (arg, msg))35 sts = 136 continue37 sts = dofile(f) or sts38 f.close()39 else:40 sys.stderr.write('%s: not found\n' % arg)41 sts = 142 if sts:43 sys.exit(sts)44numeric = re.compile('[1-9][0-9]*')45def mh(dir):46 sts = 047 msgs = os.listdir(dir)48 for msg in msgs:49 if numeric.match(msg) != len(msg):50 continue51 fn = os.path.join(dir, msg)52 try:53 f = open(fn)54 except IOError, msg:55 sys.stderr.write('%s: %s\n' % (fn, msg))56 sts = 157 continue58 sts = message(f) or sts59 return sts60def mmdf(f):61 sts = 062 while 1:63 line = f.readline()64 if not line:65 break66 if line == '\1\1\1\1\n':67 sts = message(f, line) or sts68 else:69 sys.stderr.write(70 'Bad line in MMFD mailbox: %r\n' % (line,))71 return sts72counter = 0 # for generating unique Message-ID headers73def message(f, delimiter = ''):74 sts = 075 # Parse RFC822 header76 m = rfc822.Message(f)77 # Write unix header line78 fullname, email = m.getaddr('From')79 tt = m.getdate('Date')80 if tt:81 t = time.mktime(tt)82 else:83 sys.stderr.write(84 'Unparseable date: %r\n' % (m.getheader('Date'),))85 t = os.fstat(f.fileno())[stat.ST_MTIME]86 print 'From', email, time.ctime(t)87 # Copy RFC822 header88 for line in m.headers:89 print line,90 # Invent Message-ID header if none is present91 if not m.has_key('message-id'):92 global counter93 counter = counter + 194 msgid = "<%s.%d>" % (hex(t), counter)95 sys.stderr.write("Adding Message-ID %s (From %s)\n" %96 (msgid, email))97 print "Message-ID:", msgid98 print99 # Copy body100 while 1:101 line = f.readline()102 if line == delimiter:103 break104 if not line:105 sys.stderr.write('Unexpected EOF in message\n')106 sts = 1107 break108 if line[:5] == 'From ':109 line = '>' + line110 print line,111 # Print trailing newline112 print113 return sts114if __name__ == "__main__":...

Full Screen

Full Screen

score.py

Source:score.py Github

copy

Full Screen

...14def get_eng_avg(sts):15 return sum([st.english for st in sts]) / len(sts)16def get_bio_avg(sts):17 return sum([st.biology for st in sts]) / len(sts)18def pr_sts(sts):19 for st in sts:20 print(st.info())21def select_math_larger(sts, score):22 chosen = []23 for st in sts:24 if st.math > score:25 chosen.append(st)26 return chosen27def select_chinese_less(sts, score):28 chosen = []29 for st in sts:30 if st.chinese > score:31 chosen.append(st)32 return chosen33def select_biology_higher_avg(sts):34 chosen = []35 for st in sts:36 if st.biology > get_bio_avg(sts):37 chosen.append(st)38 return chosen39def selct_english_lowest(sts):40 with open('students.txt') as f:41 for line in f:42 ts = line.strip().split()43 eng = float(ts[3])44 chosen = []45 for st in sts:46 if st.english < eng:47 chosen.append(st)48 return chosen49def read_scores():50 with open('students.txt') as f:51 line = f.readline()52 print(line)53 sts = []54 for line in f:55 ts = line.strip().split()56 #print(ts)57 name = ts[0]58 math = float(ts[1])59 chi = float(ts[2])60 eng = float(ts[3])61 bio = float(ts[4])62 st = Student(name, math, chi, eng, bio)63 sts.append(st)64 print(st.info())65 66 math_avg = get_math_avg(sts)67 chi_avg = get_chi_avg(sts)68 eng_avg = get_eng_avg(sts)69 bio_avg = get_bio_avg(sts)70 fmt = '{:<10}{:<10}{:<10}{:<10}{:<10}'71 print(fmt.format('avg:', math_avg, chi_avg, eng_avg, bio_avg))72 print('-'* 50)73 lst1 = select_math_larger(sts, 70)74 pr_sts(lst1)75 print('-'*50)76 lst2 = select_chinese_less(sts, 70)77 pr_sts(lst2)78 print('-'*50)79 lst3 = select_biology_higher_avg(sts)80 pr_sts(lst3)81 print('-'*50)82 lst4 = selct_english_lowest(sts)83 pr_sts(lst4)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful