mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
build.App: Remove some cruft
Remove code
- Explicitly marked as unused
- Meant to provide Python2 compatibility
- Meant to run App.py as main module
- Turned obsolete by removing the command functions from
Projects.py
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
ac583f76e1
commit
3370dd6236
1 changed files with 9 additions and 53 deletions
|
|
@ -1,36 +1,15 @@
|
|||
#!/usr/bin/python3 -u
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# This source code file is a merge of various build tools and a horrible mess.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import sys
|
||||
import argparse
|
||||
import pwd
|
||||
import time
|
||||
from os.path import isfile
|
||||
from os.path import isdir
|
||||
from os.path import expanduser
|
||||
from os.path import basename
|
||||
from os.path import realpath
|
||||
import subprocess
|
||||
import re
|
||||
import platform
|
||||
import datetime
|
||||
import os, sys, argparse, pwd, re
|
||||
|
||||
# meaning of pkg.requires.xxx variables
|
||||
# build: needs to be built and installed before this can be built
|
||||
# devel: needs to be installed before this-devel can be installed, i.e. before _other_ packages can be built against this
|
||||
# run: needs to be installed before this-run can be installed, i.e. before this and other packages can run with this
|
||||
|
||||
# --------------------------------------------------------------------- Python 2 / 3 compatibility stuff
|
||||
try:
|
||||
basestring
|
||||
except NameError:
|
||||
basestring = str
|
||||
|
||||
# --------------------------------------------------------------------- helpers
|
||||
|
||||
class ResultCache(object):
|
||||
|
|
@ -79,7 +58,7 @@ class App(object):
|
|||
self.opt_debug = False
|
||||
self.res_cache = ResultCache()
|
||||
self.topdir = None
|
||||
self.projs_root = expanduser("~") + '/local/src/jw.dev/proj'
|
||||
self.projs_root = os.path.expanduser("~") + '/local/src/jw.dev/proj'
|
||||
|
||||
def debug(self, *objs):
|
||||
if self.opt_debug:
|
||||
|
|
@ -91,18 +70,6 @@ class App(object):
|
|||
def err(self, *objs):
|
||||
print("ERR: ", *objs, file = sys.stderr)
|
||||
|
||||
def find_proj_path_unused(name):
|
||||
name = name.replace("dspider-", "")
|
||||
search_path = [".", "dspc/src", "dspc/src/dspcd-plugins", "dspc/src/io" ]
|
||||
for sub in search_path:
|
||||
path = self.projs_root + "/" + sub + "/" + name
|
||||
if os.path.exists(path):
|
||||
return os.path.abspath(path)
|
||||
raise Exception("module " + name + " not found below " + self.projs_root)
|
||||
|
||||
def find_proj_path_cached_unused(name):
|
||||
return self.res_cache.run(find_proj_path_unused, [ name ])
|
||||
|
||||
def proj_dir(self, name):
|
||||
if name == self.top_name:
|
||||
return self.topdir
|
||||
|
|
@ -127,9 +94,10 @@ class App(object):
|
|||
return [x for x in seq if not (x in seen or seen_add(x))]
|
||||
|
||||
def get_os(self, args = ""):
|
||||
import subprocess
|
||||
for d in [ self.projs_root + '/jw-build/scripts', '/opt/jw-build/bin' ]:
|
||||
script = d + '/get-os.sh'
|
||||
if isfile(script):
|
||||
if os.path.isfile(script):
|
||||
cmd = '/bin/bash ' + script
|
||||
if args:
|
||||
cmd = cmd + ' ' + args
|
||||
|
|
@ -148,11 +116,12 @@ class App(object):
|
|||
if pd is None:
|
||||
return None
|
||||
for r in [ pd + "/tools/html/htdocs", pd + "/htdocs", "/srv/www/proj/" + name ]:
|
||||
if isdir(r):
|
||||
if os.path.isdir(r):
|
||||
return r
|
||||
return None
|
||||
|
||||
def os_cascade(self):
|
||||
import platform
|
||||
if self.glob_os_cascade is not None:
|
||||
return self.glob_os_cascade.copy()
|
||||
r = [ 'os', platform.system().lower() ]
|
||||
|
|
@ -320,7 +289,7 @@ class App(object):
|
|||
|
||||
def get_modules_from_project_txt(self, names, sections, keys, add_self, scope,
|
||||
names_only = True):
|
||||
if isinstance(keys, basestring):
|
||||
if isinstance(keys, str):
|
||||
keys = [ keys ]
|
||||
#r = set()
|
||||
r = []
|
||||
|
|
@ -477,8 +446,6 @@ class App(object):
|
|||
return r[1::]
|
||||
return ''
|
||||
|
||||
# ----------------------------------------------------------------- commands
|
||||
|
||||
def contains(self, small, big):
|
||||
for i in xrange(len(big)-len(small)+1):
|
||||
for j in xrange(len(small)):
|
||||
|
|
@ -578,17 +545,6 @@ class App(object):
|
|||
if self.topdir:
|
||||
self.top_name = self.res_cache.run(self.read_value, [self.topdir + '/make/project.conf', 'build', 'name'])
|
||||
if not self.top_name:
|
||||
self.top_name = re.sub('-[0-9.-]*$', '', basename(realpath(self.topdir)))
|
||||
self.top_name = re.sub('-[0-9.-]*$', '', os.path.basename(os.path.realpath(self.topdir)))
|
||||
|
||||
try:
|
||||
return self.run_from_cmd_module(args.cmd, sys.argv[(len(self.global_args) + 1)::])
|
||||
except:
|
||||
raise
|
||||
pass
|
||||
cmd_name = 'cmd_' + args.cmd.replace('-', '_')
|
||||
cmd = getattr(self, cmd_name)
|
||||
cmd(sys.argv[(len(self.global_args) + 1)::])
|
||||
|
||||
if __name__ == "__main__":
|
||||
projects = App()
|
||||
projects.run()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue