Menu

[62a5d4]: / install.py  Maximize  Restore  History

Download this file

160 lines (121 with data), 4.0 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
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/usr/bin/env python
import time, sys, os, re, stat
import string, pickle
import commands, site
import distutils.sysconfig
installerdir = sys.argv[0][:sys.argv[0].rfind("/")] + "/"
depfailed = False
PROJNAME = "pyedit"
PROJLIB = "pyedlib"
PROJLIB2 = "panglib"
# ------------------------------------------------------------------------
# Return True if exists
def isdir(fname):
try:
ss = os.stat(fname)
except:
return False
if stat.S_ISDIR(ss[stat.ST_MODE]):
return True
return False
# ------------------------------------------------------------------------
# Make dir if it does not exist
def softmkdir(dirx):
if not isdir(dirx):
#print "Creating directory '" + dirx + "'"
os.mkdir(dirx, 0755)
if not isdir(dirx):
return False
return True
# See if path contains user dirs:
path = os.environ['PATH']; home = os.environ['HOME']
user = os.environ['USER']
#print "path", path
#print "home", home, "user", user
if commands.getoutput("whoami").strip() != "root":
'''gotbin = ""
for aa in str.split(path, ":"):
if aa.find(home) >= 0:
gotbin = aa
if gotbin == "":
print "FAILED: You must be root to install pangview."
sys.exit()
else:
print "installing in", gotbin
sys.exit()'''
print "FAILED: You must be root to install", PROJNAME
sys.exit()
#print "Verifying dependencies:"
try:
import pygtk
pygtk.require('2.0')
import gtk
import gobject
except ImportError:
print " >>> Missing Dependencies: Python GTK+ bindings (python-gtk2)."
depfailed = True
try:
import gnome.ui
except ImportError:
print " >>> Missing Dependencies: Python GNOME bindings (python-gnome2)."
depfailed = True
# not stricly needed, just a validity check
prefix = sys.prefix
if not isdir(prefix):
print " >>> Missing Dependencies: sys prefix dir does not exist."
depfailed = True
pylib = distutils.sysconfig.get_python_lib()
if not isdir(pylib):
print " >>> Missing Dependencies: Python Library dir does not exist."
depfailed = True
# ------------------------------------------------------------------------
if depfailed:
print "FAILED: Dependencies not met. Exiting."
sys.exit(1)
print "All dependencies are met."
shared = "/usr/share" + "/" + PROJNAME
bindir = "/usr/bin"
#print "prefix:", prefix
#print "libdir:", libdir
# --- file --- target dir ---- exec flag ----
filelist = \
['pyedit.py', bindir, True ], \
['pangview.py', bindir, True ], \
['README', shared, False ], \
['HISTORY', shared, False ], \
# --- dir --- target dir ---- root owner flag ----
dirlist = \
[PROJNAME, "/usr/share", True ], \
[PROJLIB, pylib, True ], \
[PROJLIB2, pylib, True ], \
# Copy all to target:
print "Making target directories:"
for source, dest, exe in dirlist:
targ = dest + "/" + source
print " '" + targ + "'"
softmkdir(targ)
print "Copying files:"
for source, dest, exe in filelist:
try:
targ = dest + "/" + source
print " '" + source + "'\t->'" + targ + "'"
# Do not overwrite newer stuff
commands.getoutput("cp -u " + source + " " + targ)
if exe:
os.chmod(targ, 0755) # Root can rwx; can rx
else:
os.chmod(targ, 0644) # Root can rw; others r
except:
print sys.exc_info()
print "Copying directories:"
for source, dest, exe in dirlist:
try:
print " '" + source + "'\t->'" + dest + "'"
commands.getoutput ("cp -a " + source + " " + dest)
if exe:
commands.getoutput(" chown root.root " + dest + "/" + source + "/*")
except:
print sys.exc_info()
print
print "You may now use the", PROJNAME, "utility on your system."
print
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.