From 0dbb7026782ec60be1b65e658129a6a19bbd4b97 Mon Sep 17 00:00:00 2001 From: Josue Gomez Date: Tue, 14 May 2019 18:30:47 -0600 Subject: [PATCH] make it package --- __init__.py | 23 ++++++++--------------- oracle.py | 4 ++-- pysyspath2 | 10 ---------- pysyspath3 | 10 ---------- sendmail.py | 8 ++++---- 5 files changed, 14 insertions(+), 41 deletions(-) delete mode 100755 pysyspath2 delete mode 100755 pysyspath3 diff --git a/__init__.py b/__init__.py index b9ae084..a81cf2b 100644 --- a/__init__.py +++ b/__init__.py @@ -6,15 +6,14 @@ To use, simply 'import pyutils' shellExecute can receive a cmd as str or arr example >>> pyutils.shell_execute('date') (b'mi\xc3\xa9 ene 30 11:35:00 CST 2019\n', b'') - >>> pyutils.shell_execute(['echo',"'hola mundo'"]) - (b"'hola mundo'\n", b'') - + >>> pyutils.shell_execute(['echo',"'hello world'"]) + (b"'hello world'\n", b'') """ __author__ = 'Josue Gomez ' __maintainer__ = "Josue Gomez" __email__ = "jgomez@binkfe.com" -__license__ = "GPL" +__license__ = "MIT" __version__ = '2.0' __all__ = ['', ] __status__ = "production" @@ -25,12 +24,6 @@ import sys import subprocess -def pysyspath(): - print(sys.version) - for pth in sys.path: - print(pth) - - def resize_tty(rows, cols): sys.stdout.write("\x1b[8;{rows};{cols}t".format(rows=rows, cols=cols)) @@ -42,11 +35,11 @@ def shell_execute(cmd, stdin=None): def progress_bar(progress, total, status=''): - ttysize = shell_execute(['stty','size']) - ttysize = ttysize[0].decode().split(' ') - barlen = round(int(ttysize[1])/100*90) - fill_len = int(round(barlen * progress / float(total))) + tty_size = shell_execute(['stty', 'size']) + tty_size = tty_size[0].decode().split(' ') + bar_len = round(int(tty_size[1])/100*90) + fill_len = int(round(bar_len * progress / float(total))) percent = round(100.0 * progress / float(total), 1) - bar = '■' * fill_len + '-' * (barlen - fill_len) + bar = '■' * fill_len + '-' * (bar_len - fill_len) sys.stdout.write('[%s] %s%s ...%s\r' % (bar, percent, '%', status)) sys.stdout.flush() diff --git a/oracle.py b/oracle.py index 342ea0b..52e7bf3 100644 --- a/oracle.py +++ b/oracle.py @@ -8,8 +8,8 @@ APP_CTX_ENTRIES = [ def dbmsoutput(cursor): """ - dbmsoutput must be enabled before execute statement - cur.callproc("dbms_output.enable",(None,)) + dbmsoutput must be enabled before execute statement + cur.callproc("dbms_output.enable",(None,)) """ output = str() status = cursor.var(cx_Oracle.NUMBER) diff --git a/pysyspath2 b/pysyspath2 deleted file mode 100755 index 31a36e0..0000000 --- a/pysyspath2 +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python2 -import pyutils as utl - - -def main(): - utl.pysyspath() - - -if __name__ == "__main__": - main() diff --git a/pysyspath3 b/pysyspath3 deleted file mode 100755 index 5b4a226..0000000 --- a/pysyspath3 +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env python3 -import pyutils as utl - - -def main(): - utl.pysyspath() - - -if __name__ == "__main__": - main() diff --git a/sendmail.py b/sendmail.py index d5dedba..bbd2086 100644 --- a/sendmail.py +++ b/sendmail.py @@ -33,13 +33,13 @@ class SendMail: self.conn.starttls() self.conn.login(self.user, self.pssw) - def content(self, fromaddr, toaddr, subject, msg): - if not isinstance(toaddr, list): + def content(self, from_address, to_address, subject, msg): + if not isinstance(to_address, list): raise AssertionError('destination address should be a list []') self.msg = MIMEMultipart() self.msg['Subject'] = subject - self.msg['From'] = fromaddr - self.msg['To'] = COMMASPACE.join(toaddr) + self.msg['From'] = from_address + self.msg['To'] = COMMASPACE.join(to_address) self.msg.attach(MIMEText(msg, 'html')) def attach(self, files):