Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #39408
| Path | csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <sntshkmr60@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'args': 0.04; 'elif': 0.04; 'sys': 0.05; 'parser': 0.07; 'problem?': 0.07; 'setup.py': 0.07; 'shutil': 0.07; 'python': 0.09; 'exists,': 0.09; 'subject:script': 0.09; 'url:github': 0.09; 'subject:Help': 0.10; 'def': 0.10; "skip:' 30": 0.15; 'to:name:python-list': 0.15; 'argparse': 0.16; 'expected,': 0.16; 'install.': 0.16; 'subject:argparse': 0.16; 'sudo': 0.16; 'uninstall': 0.16; 'appropriate': 0.20; 'skip:p 30': 0.20; 'import': 0.21; 'installed': 0.23; 'script': 0.24; 'message-id:@mail.gmail.com': 0.27; 'initial': 0.28; 'privileges': 0.29; "skip:' 10": 0.30; "skip:' 20": 0.32; 'running': 0.32; 'getting': 0.33; 'skip:s 30': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'me?': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'locations': 0.35; 'subject:with': 0.36; 'skip:p 20': 0.36; 'files': 0.38; 'skip:o 20': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'skip:u 10': 0.60; 'further': 0.61; 'skip:\xc2 10': 0.62; 'skip:n 10': 0.63; 'here': 0.65; '8bit%:100': 0.70; 'subject:this': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=f+UlLng+Bc6hp1oJ222f2I9vFHFI0NjuMnlgjnBTSzI=; b=R/3np17myleMYLi7wqiooSMg9jNIn2MyMzxKoKJR0mvcxHm7JLzAhCMMPQyy/a8SNb nVrNNeIjslXjltX080NDqYH2eF+68NzozMCD66e9dK0SF06sMqUgtGVNZcL8GbJAM8Gk e2vxmJ3y1s5l/rR0zBbLpHrPozdWiXW49nA/pRhvFwuy8Du2mKzqbpWlFwWKMhoKZ79m 6Tdx0TIUxl4QJCQxfbatsjNxxxdyFAccDz5lh5IR9M2aj8ILHD6tcCVgucJd5FNZQyib 7I2N+jHHuyKKC8+7d/E6UO/cGbraueBnpNtzm7Fp0BDFianjcJ4ey8htgry9jelpQn22 T2uA== |
| MIME-Version | 1.0 |
| X-Received | by 10.152.112.231 with SMTP id it7mr19788993lab.10.1361441142546; Thu, 21 Feb 2013 02:05:42 -0800 (PST) |
| Date | Thu, 21 Feb 2013 15:35:42 +0530 |
| Subject | Help me debug this script with argparse and if statements |
| From | Santosh Kumar <sntshkmr60@gmail.com> |
| To | python-list <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=f46d04071533af1fc204d639374b |
| 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.2150.1361441149.2939.python-list@python.org> (permalink) |
| Lines | 144 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1361441149 news.xs4all.nl 6964 [2001:888:2000:d::a6]:48730 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:39408 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
I have this script (setup.py):
import os
import sys
import shutil
from argparse import ArgumentParser
if os.getuid() != 0:
sys.exit("can't proceed, sudo privileges needed")
installManto = '/usr/share/man/man1/'
installBinTo = '/usr/local/bin/'
capsLoc = '/usr/local/bin/myapp'
mansLoc = '/usr/share/man/man1/mymanpage.1.gz'
def install():
shutil.copy2('doc/mymanpage.1.gz', installManto)
shutil.copy2('myapp', installBinTo)
def uninstall():
os.remove(capsLoc)
os.remove(mansLoc)
def update():
uninstall()
install()
parser = ArgumentParser(
prog='setup.py',
description='installer for myapp',
)
parser.add_argument(
'install',
nargs='?',
help='install myapp'
)
parser.add_argument(
'uninstall',
nargs='?',
help='uninstall myapp'
)
args = parser.parse_args()
if args.install:
if os.path.isfile(capsLoc) or os.path.isfile(mansLoc):
print("The files exists, getting ready to update.")
update()
else:
print("Running the initial setup...")
install()
elif args.uninstall:
print("Uninstalling..")
uninstall()
else:
parser.print_help()
Here is what happens:
1. I can copy the *myapp* and *mymanpage.1.gz* to their appropriate
locations with *sudo python setup.py install*. This is what I expected,
their is no problem upto here.
2. Running* python setup.py uninstall* *copies* the files instead of
removing them.
3. Running * python setup.py uninstall *when installed *updates* the files
instead of removing them.
So what's the problem? What is the fix? Any further tips for me?
--
Twitter <https://twitter.com/sntshk> | Github <https://github.com/santosh>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Help me debug this script with argparse and if statements Santosh Kumar <sntshkmr60@gmail.com> - 2013-02-21 15:35 +0530
csiph-web