Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51224
| 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 | <joshua.landau.ws@gmail.com> |
| 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 <joshua@landau.ws> |
| 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 <python-list@python.org> |
| 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 <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5100.1374761084.3114.python-list@python.org> (permalink) |
| 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 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On 25 July 2013 14:24, Devyn Collier Johnson <devyncjohnson@gmail.com>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.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Critic my module Joshua Landau <joshua@landau.ws> - 2013-07-25 15:03 +0100
csiph-web