Commits

zhangchunlin  committed dc63ec3

初步可用了

  • Participants
  • Parent commits eb21be3

Comments (0)

Files changed (4)

File apps/Ablog/templates/index.html

+<html>
+<head>
+<meta content="text/html; charset=utf-8" http-equiv="content-type">
+<title>autobuild log</title>
+</head>
+<body>
+{{
+import os
+for dp in logpaths:
+    out.write("<h1>%s</h1><br>"%dp, escape=False)
+    for path in logpaths[dp]:
+        logfp = os.path.join(dp,path)
+        out.write('<li><a href="/vlog/%s">%s</a></li>'%(logfp,path), escape=False)
+}}
+</body>
+</html>

File apps/Ablog/views.py

 #coding=utf-8
-from uliweb import expose
+from uliweb import expose,settings
+import os
+
+def get_log_paths():
+    dps = []
+    for d in os.listdir(settings.ABLOG.AB_DIR):
+        builddp = os.path.join(settings.ABLOG.AB_DIR,d,"build")
+        if os.path.exists(builddp):
+            logdp = os.path.join(builddp,"out/target/product")
+            if os.path.exists(logdp):
+                dps.append(logdp)
+            else:
+                for d2 in os.listdir(builddp):
+                    logdp = os.path.join(builddp,d2,"out/target/product")
+                    if os.path.exists(logdp):
+                        dps.append(logdp)
+    
+    paths = {}
+    for dp in dps:
+        list = []
+        for item in os.listdir(dp):
+            path = os.path.join(dp,item)
+            if (os.path.isfile(path) and (path.find("log")!=-1)):
+                list.append(item)
+        rdp = os.path.relpath(dp,settings.ABLOG.AB_DIR)
+        paths[rdp]=list
+    return paths
 
 @expose('/')
 def index():
-    return '<h1>Hello, Uliweb</h1>'
+    return {"logpaths":get_log_paths()}
+
+@expose('/vlog/<path:rfp>')
+def vlog(rfp):
+    from uliweb.utils.textconvert import text2html
+    fp = os.path.join(settings.ABLOG.AB_DIR,rfp)
+    f = open(fp)
+    c = f.read()
+    f.close()
+    return text2html(c)

File apps/local_settings.ini.example

+[ABLOG]
+AB_DIR = "YOUR_AUTOBUILDSLAVE_DIR_PATH"

File apps/settings.ini

 [GLOBAL]
 DEBUG = True
 
-#INSTALLED_APPS = [
-#    'uliweb.contrib.staticfiles',
-#    ]
+INSTALLED_APPS = [
+    #'uliweb.contrib.develop',
+    'Ablog',
+    ]