Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'python.': 0.02; 'python3': 0.07; "(i'd": 0.09; 'arguments': 0.09; 'bash': 0.09; 'collier': 0.09; 'correct,': 0.09; 'forcing': 0.09; 'restart': 0.09; 'subject:module': 0.09; 'sys,': 0.09; 'python': 0.11; 'def': 0.12; "wouldn't": 0.14; '*args):': 0.16; 'cmd': 0.16; 'command:': 0.16; 'dict': 0.16; 'hostname': 0.16; "module's": 0.16; 'python3.': 0.16; 'reboot': 0.16; 'self.command': 0.16; '\xc2\xa0i': 0.16; 'sender:addr:gmail.com': 0.17; 'wrote:': 0.18; 'module': 0.19; 'skip:p 40': 0.19; 'command': 0.22; 'import': 0.22; 'email addr:gmail.com>': 0.22; 'shell': 0.22; 'looks': 0.24; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'leave': 0.29; 'skip:p 30': 0.29; 'unix': 0.29; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; 'work.': 0.31; 'easier': 0.31; 'closer': 0.31; 'skip:! 10': 0.31; 'allows': 0.31; 'class': 0.32; 'probably': 0.32; 'skip:c 30': 0.32; 'linux': 0.33; 'skip:_ 10': 0.34; 'display': 0.35; 'classes': 0.35; 'common': 0.35; 'something': 0.35; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'licensed': 0.36; 'module.': 0.36; 'doing': 0.36; 'material': 0.36; 'wrong': 0.37; 'easily': 0.37; 'architecture': 0.38; 'skip:& 10': 0.38; 'skip:[ 10': 0.38; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'users': 0.40; 'release': 0.40; 'how': 0.40; 'commands': 0.60; 'free': 0.61; 'skip:* 40': 0.61; 'simple': 0.61; "you're": 0.61; 'first': 0.61; 'you.': 0.62; 'name': 0.63; 'july': 0.63; 'skip:n 10': 0.64; 'more': 0.64; 'combining': 0.68; 'internet': 0.71; 'repeat': 0.74; 'soon,': 0.74; 'boa': 0.84; 'dolphin': 0.84; 'env': 0.84; 'glance': 0.84; 'shutdown': 0.84; 'url:ls': 0.84; 'yourself,': 0.95; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; bh=JqFa+HwEqAQA2UeJWFaO9EfYVAidRDvpE6hPPUyjXis=; b=HJVRIAUZVvdvKF67MrsyBhEC08oann7ooGLoEOjBEK9N3Elvi3IddZfESq6QxDjXiW r6bdJuEnhLx6dlTr0Kw1W4rpbzZwJiaerTItdJLHyQeQLptCmU0IaVY086wno8WBVNhw tNuzBW1BI4COTRRG/XJzHQ1BQuvvDFui/8LQ4xm0dB6ZgggiLu/OkBzTrL2rFhidR5L4 txQNhL4x9pBVnqavuAEoTlWOYjrSnYLQ5AoKLWTJ3tK+Z/XOJE4unDMzhGqTs4jEStdK EF/VB2Sr3m0asBUkhVzrc66KYFMn+fJ7WTOIz3vYDh3f0DzzOwNji2MbMk/OBku0STw6 C2yw== X-Received: by 10.152.4.232 with SMTP id n8mr19443349lan.29.1374761075337; Thu, 25 Jul 2013 07:04:35 -0700 (PDT) MIME-Version: 1.0 Sender: joshua.landau.ws@gmail.com In-Reply-To: <51F1270E.6000704@Gmail.com> References: <51F1270E.6000704@Gmail.com> From: Joshua Landau Date: Thu, 25 Jul 2013 15:03:55 +0100 X-Google-Sender-Auth: yVK_1o6_SDXl_ghq66jjbt-FubY Subject: Re: Critic my module To: Python Mailing List Content-Type: multipart/alternative; boundary=089e013d1eb88beeee04e2568175 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 227 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1374761084 news.xs4all.nl 15923 [2001:888:2000:d::a6]:33653 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51224 --089e013d1eb88beeee04e2568175 Content-Type: text/plain; charset=UTF-8 On 25 July 2013 14:24, Devyn Collier Johnson wrote: > Aloha Python Users! > > I made a Python3 module that allows users to use certain Linux shell > commands from Python3 more easily than using os.system(), > subprocess.Popen(), or subprocess.getoutput(). This module (once placed > with the other modules) can be used like this > > import boash; boash.ls() > > I attached the module. I plan to release it on the Internet soon, but > feel free to use it now. It is licensed under LGPLv3. > > The name comes from combining "Boa" with "SHell". Notice that the > module's name almost looks like "BASH", a common Linux shell. The Boa is a > constrictor snake. This module makes Unix shells easier to use via Python3. > This brings the system shell closer to the Python shell. > 1) Have you tested everything? At first glance some of those look like they won't work. 2) Whenever you repeat yourself, *especially* at this magnitude, you're doing something seriously wrong - *especially* in Python. *Completely-untestedly-and-super-quick-hackedly:* import re, sys, subprocess, platform class Command: def __init__(self, command=None): self.command = command def __call__(self, *args): command_list = [self.command] if self.command else [] command_list.extend(args) print(subprocess.getoutput([command_list])) def uname(): print(platform.uname()) def lsof(): print(subprocess.getoutput(lsof)) apropos = Command("apropos") arora = Command("(arora &)") dir = Command("dir") dolphin = Command("(dolphin &)") env = Command("env") finger = Command("finger") firefox = Command("(firefox &)") free = Command("free") geany = Command("(geany &)") getcwd = Command("pwd") go_back = Command("cd !!:1") halt = Command("shutdown -h now") hostname = Command("hostname") konqueror = Command("(konqueror &)") ls = Command("ls") lsof = Command("lsof") man = Command("man") mplayer = Command("(mplayer &)") nautilus = Command("(nautilus &)") nvlc = Command("(nvlc &)") opera = Command("(opera &)") pwd = Command("pwd") qvlc = Command("(qvlc &)") repeat = Command("!") runlevel = Command("runlevel") rvlc = Command("(rvlc &)") smplayer = Command("(smplayer &)") svlc = Command("(svlc &)") vlc = Command("(vlc &)") whoami = Command("whoami") xterm = Command("(xterm &)") arch = architecture = Command("arch") bash = cmd = command = shell = Command() last_cmd = last_command = repeat_cmd = Command("!!") ll = vdir = Command("ls - l") no_login = no_logins = nologin = nologins = Command("shutdown -k now") power_down = power_off = powerdown = poweroff = Command("shutdown -P now") reboot = restart = Command("shutdown -r now") shut_down = shutdown = Command("shutdown now") clear_bash_hist = clear_bash_history = clear_hist = clear_history = \ del_bash_hist = del_hist = delete_bash_hist = delete_bash_history = \ delete_hist = delete_history = Command("history -c") ejcd = ejdvd = eject_cd = eject_cdrom = eject_disc = eject_disc_tray = \ eject_dvd = eject_tray = ejectcd = ejectcdrom = ejectdisc = ejectdisctray = ejectdvd = ejecttray = ejtray = Command("eject cdrom1") I wouldn't actually do it like this (I'd probably start with a dict and add to a class programmatically), but this is a simple display of how one can use classes and other meta-constructs to make things look nicer. It also doesn't deal with forcing the number of arguments to be correct, but this is demo material and so I leave that to you. --089e013d1eb88beeee04e2568175 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On 25 July 2013 14:24, Devyn Collier Johnson <devyn= cjohnson@gmail.com> wrote:
Aloha Python Users!

=C2=A0 =C2=A0I made a Python3 module that allows users to use certain Linux= shell commands from Python3 more easily than using os.system(), subprocess= .Popen(), or subprocess.getoutput(). This module (once placed with the othe= r modules) can be used like this

import boash; boash.ls()<= br>
=C2=A0 =C2=A0I attached the module. I plan to release it on the Internet so= on, but feel free to use it now. It is licensed under LGPLv3.

=C2=A0 =C2=A0The name comes from combining "Boa" with "SHell= ". Notice that the module's name almost looks like "BASH"= ;, a common Linux shell. The Boa is a constrictor snake. This module makes = Unix shells easier to use via Python3. This brings the system shell closer = to the Python shell.

1) Have you tested everything? At first gl= ance some of those look like they won't work.

= 2) Whenever you repeat yourself, *especially* at this magnitude, you're= doing something seriously wrong - *especially* in Python.

*Completely-untestedly-and-super-quick-hackedly:*
=

import re, sys, subprocess, platform
cla= ss Command:
def __init__(self, command=3DNone):
self.command =3D c= ommand
def __c= all__(self, *args):
command_list =3D [self.command] if self.command else []
command_list.exten= d(args)
print= (subprocess.getoutput([command_list]))
def uname():
=
print(platform.uname())<= /div>
def lsof():
print(subprocess.getoutput(lsof))
apropos =C2=A0 =3D = Command("apropos")
arora =C2=A0 =C2=A0 =3D Command("(arora &)")
=
dir =C2=A0 =C2=A0 =C2=A0 =3D Command("dir")
dolphi= n =C2=A0 =3D Command("(dolphin &)")
env =C2=A0 =C2= =A0 =C2=A0 =3D Command("env")
finger =C2=A0 =C2=A0=3D Command("finger")
firefox =C2= =A0 =3D Command("(firefox &)")
free =C2=A0 =C2=A0 = =C2=A0=3D Command("free")
geany =C2=A0 =C2=A0 =3D Comma= nd("(geany &)")
getcwd =C2=A0 =C2=A0=3D Command(&qu= ot;pwd")
go_back =C2=A0 =3D Command("cd !!:1")
halt =C2=A0 = =C2=A0 =C2=A0=3D Command("shutdown -h now")
hostname = =C2=A0=3D Command("hostname")
konqueror =3D Command(&qu= ot;(konqueror &)")
ls =C2=A0 =C2=A0 =C2=A0 =C2=A0=3D Command("ls")
ls= of =C2=A0 =C2=A0 =C2=A0=3D Command("lsof")
man =C2=A0 = =C2=A0 =C2=A0 =3D Command("man")
mplayer =C2=A0 =3D Com= mand("(mplayer &)")
nautilus =C2=A0=3D Command(&quo= t;(nautilus &)")
nvlc =C2=A0 =C2=A0 =C2=A0=3D Command("(nvlc &)")
opera =C2=A0 =C2=A0 =3D Command("(opera &)")
pwd= =C2=A0 =C2=A0 =C2=A0 =3D Command("pwd")
qvlc =C2=A0 = =C2=A0 =C2=A0=3D Command("(qvlc &)")
repeat =C2=A0 =C2=A0=3D Command("!")
runlevel =C2=A0=3D= Command("runlevel")
rvlc =C2=A0 =C2=A0 =C2=A0=3D Comma= nd("(rvlc &)")
smplayer =C2=A0=3D Command("(sm= player &)")
svlc =C2=A0 =C2=A0 =C2=A0=3D Command("(= svlc &)")
vlc =C2=A0 =C2=A0 =C2=A0 =3D Command("(vlc &)")
whoami =C2=A0 =C2=A0=3D Command("whoami")
xterm =C2= =A0 =C2=A0 =3D Command("(xterm &)")
arch =3D archit= ecture =3D Command("arch")
bash =3D cmd =3D command =3D shell =3D Command()
last_cm= d =3D last_command =3D repeat_cmd =3D Command("!!")
ll =3D vdir =3D Command("ls - l")
no_login =3D no_= logins =3D nologin =3D nologins =3D Command("shutdown -k now")
power_down =3D power_off =3D powerdown =3D poweroff =3D Command(= "shutdown -P now")
reboot =3D restart =3D Command(&= quot;shutdown -r now")
shut_down =3D shutdown =3D Comman= d("shutdown now")
clear_bash_hist =3D clear_bash_history =3D clear_hist =3D clear_= history =3D \
del_bash_hist =3D del_hist =3D delete_bash_hist =3D delete_bash_history= =3D \
delete_hist =3D delete_h= istory =3D Command("history -c")
ejcd =3D ejdvd =3D eje= ct_cd =3D eject_cdrom =3D eject_disc =3D eject_disc_tray =3D \
eject_dvd =3D eject_tr= ay =3D ejectcd =3D ejectcdrom =3D
ejectdisc =3D eject= disctray =3D ejectdvd =3D ejecttray =3D ejtray =3D Command("eject cdro= m1")



I wo= uldn't actually do it like this (I'd probably start with a dict and= add to a class programmatically), but this is a simple display of how one = can use classes and other meta-constructs to make things look nicer. It als= o doesn't deal with forcing the number of arguments to be correct, but = this is demo material and so I leave that to you.
--089e013d1eb88beeee04e2568175--