make it package

This commit is contained in:
Josue Gomez 2019-05-14 18:30:47 -06:00
parent 8a45a653a3
commit 0dbb702678
5 changed files with 14 additions and 41 deletions

View File

@ -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 <jgomez@jesrat.com>'
__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()

View File

@ -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)

View File

@ -1,10 +0,0 @@
#!/usr/bin/env python2
import pyutils as utl
def main():
utl.pysyspath()
if __name__ == "__main__":
main()

View File

@ -1,10 +0,0 @@
#!/usr/bin/env python3
import pyutils as utl
def main():
utl.pysyspath()
if __name__ == "__main__":
main()

View File

@ -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):