Skip to content
Snippets Groups Projects
Commit c8d178c2 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Remove the obsolete script cpAdmin.

parent 77fa4b6f
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
NAME
cpAdmin -- copy the web2py admin file in the current application
SYNOPSIS
cpAdmin [options]
DESCRIPTION
Copy or remove the web2py admin file in the current application.
Usefull to fix some problem with the database
EXAMPLES
> cpAdmin -h
> cpAdmin
> cpAdmin --clean
AUTHOR
R. Le Gac, renaud.legac@free.fr
Copyright (c) 2012 R. Le Gac
"""
import os
import shutil
import sys
DIRS = ['static/css',
'static/images',
'static/js']
FILES = ['controllers/appadmin.py',
'static/css/anytime.css',
'static/css/base.css',
'static/css/handheld.css',
'static/css/superfish-navbar.css',
'static/css/superfish-vertical.css',
'static/css/superfish.css',
'static/images/arrows-ffffff.png',
'static/images/css3buttons_backgrounds.png',
'static/images/css3buttons_icons.png',
'static/images/poweredby.png',
'static/images/shadow.png',
'static/images/ui-icons_222222_256x240.png',
'static/js/anytime.js',
'static/js/dd_belatedpng.js',
'static/js/jquery.js',
'static/js/modernizr-1.7.min.js',
'static/js/superfish.js',
'static/js/web2py_ajax.js',
'static/favicon.ico',
'static/favicon.png',
'views/appadmin.html',
'views/generic.html',
'views/generic.json',
'views/generic.jsonp',
'views/generic.load',
'views/generic.pdf',
'views/generic.rss',
'views/generic.xml',
'views/layout.html',
'views/web2py_ajax.html',]
def check():
"""check that the reference application is there.
"""
path = os.path.join(opt.web2py, opt.refapp)
if not os.path.exists(path):
print "\n\tThe reference web2py application foo is missing"
print "\tUse the option -w to specified another ones.\n"
sys.exit(0)
def clean():
"""clean admin files.
"""
# remove individual files
for path in FILES:
if os.path.exists(path):
print "\removing", path
os.remove(path)
# remove empty directories
for path in DIRS:
try:
print"\tremoving", path
os.rmdir(path)
except:
pass
def copy():
"""copy admin files in the current applications
"""
# create directories
for path in DIRS:
if not os.path.exists(path):
print "\tcreating", path
os.mkdir(path)
# copy files from reference applications
for dest in FILES:
if not os.path.exists(dest):
src = os.path.join(opt.web2py, opt.refapp, dest)
print "\tcopying", dest
shutil.copy(src, dest)
if __name__ == '__main__':
import optparse
# define script options
ops = optparse.OptionParser()
ops.add_option("-c", "--clean",
action="store_true",
dest= "clean",
help= "remove admin files and exit.")
ops.add_option("-r", "--reference-application",
dest= "refapp",
help= "name of the reference applications [%default].")
ops.add_option("-w", "--web2py",
dest= "web2py",
help= "path to the web2py applications [%default].")
ops.set_defaults(clean=False,
refapp='foo',
web2py=os.path.expanduser('~/myweb/web2py/applications'))
(opt, args) = ops.parse_args()
# clean the admin file and exit
if opt.clean:
print "removing admin files..."
clean()
print "removing is successful !"
sys.exit(0)
# check that reference application exists
# copy admin files from the reference application and exit
check()
print "adding admin files..."
copy()
print "adding is successful !"
sys.exit(0)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment