summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan S. Arnold <ryan.arnold@linaro.org>2017-01-27 04:34:09 +0000
committerRyan S. Arnold <ryan.arnold@linaro.org>2017-01-27 18:26:21 +0000
commite6237083f4d39c01f21752382dc5d53a2dfbbc04 (patch)
tree5f8db10dbb6e219e90ecf506b20365a0e366a7d0
parente5ff0574bf4d7167ff69d94f5f9420341acca921 (diff)
rn.py: Copy rendered files to $USER/public_html/
Copy rendered files to $USER/public_html/ if the users requests. This allows the user to verify that the rendered files are correct. Change-Id: I3c6b6ac48670a0954082d82a541d1efed2a2e5a9
-rw-r--r--rn.py37
1 files changed, 34 insertions, 3 deletions
diff --git a/rn.py b/rn.py
index 819475f..1d70326 100644
--- a/rn.py
+++ b/rn.py
@@ -4,7 +4,10 @@
import argparse
import logging
import os
+import pwd
import sys
+import shutil
+import glob
# handle_exit is a context manager which guarantees that the project temporary
# directories are cleaned up when there are signals.
from linaropy.handle_exit import handle_exit
@@ -103,6 +106,9 @@ def generate(track, to_date, to_series, gccsource, persist):
'Please enter the location of the changelog csv file: ',
"6.1-2016.06.csv")
+ username=pwd.getpwuid(os.getuid()).pw_name
+ public_html_dir= "/home/%s/public_html/" % username
+
next_rn.update_series_readmes()
while ans:
next_rn.rn_series.print_log(1)
@@ -114,10 +120,35 @@ def generate(track, to_date, to_series, gccsource, persist):
traceback.print_exc(file=sys.stdout)
print_info("Please correct the template and try again.")
+ # The default location to tell the user to look for generated files.
+ # If there is a webserver this is overwritten if the users wants it.
+ dest_dir=rnProj[0].projdir
+ if os.path.isdir(public_html_dir):
+ todir=public_html_dir + os.path.basename(dest_dir) + "/"
+ answer = yninput(
+ "Would you like to copy the .txt, .html, and .textile"
+ " files to your %s directory?" % todir, "N")
+
+ if answer == "y":
+ dest_dir=todir
+ if not os.path.isdir(dest_dir):
+ os.mkdir(dest_dir, 0755)
+
+ for file in glob.glob(r'%s/*.txt' % rnProj[0].projdir):
+ shutil.copy(file, dest_dir)
+ for file in glob.glob(r'%s/*.html' % rnProj[0].projdir):
+ shutil.copy(file, dest_dir)
+ for file in glob.glob(r'%s/*.textile' % rnProj[0].projdir):
+ shutil.copy(file, dest_dir)
+
+ # If the user asked for the files to be copied to public_html then
+ # this will indicate that directory, otherwise dest_dir will remain
+ # the tmp directory.
print_info(
- "Please direct your browser to the rendered .html files in"
- " %s%s%s%s and make sure that they look correct."
- % (BOLD, RED, rnProj[0].projdir, NC))
+ "Please direct your browser to the rendered .html, .textile and"
+ " .txt files in %s%s%s%s and make sure that they look correct."
+ % (BOLD, RED, dest_dir, NC))
+
ans = next_rn.update_series_readmes()
# Verify that the GCC Source is located where it says it is.