-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfeatureserver_install_config.py
More file actions
37 lines (28 loc) · 1.21 KB
/
featureserver_install_config.py
File metadata and controls
37 lines (28 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
"""Script to install a FeatureServer config from an egg installation."""
import sys
from optparse import OptionParser
def install(dest):
try:
f = open(dest, "w")
except IOError, E:
print "Unable to open destination file %s. Perhaps you need permission to write there?\n(Error was: %s)" % (dest, E)
sys.exit(1)
try:
import pkg_resources
filename = pkg_resources.resource_filename("FeatureServer", "featureserver.cfg")
cfg = open(filename, "r")
except Exception, E:
print "Unable to open source file.\n(Error was: %s)" % (E)
sys.exit(1)
f.write(cfg.read())
f.close()
cfg.close()
print "Successfully copied file %s to %s." % (filename, dest)
if __name__ == "__main__":
parser = OptionParser(usage="""%prog [options]
This script is a helper script designed to install the default FeatureServer
configuration when FeatureServer is installed from an egg.""")
parser.add_option('-d', '--dest', dest="dest", help="install to FILE. Default is /etc/featureserver.cfg", default="/etc/featureserver.cfg", metavar="FILE")
(options, args) = parser.parse_args()
install(options.dest)