Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. FROM ubuntu
  2. # Install requirements fot the flask app
  3. RUN apt-get clean && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && DEBIAN_FRONTEND=noninteractive apt-get install -y
  4. python3
  5. python3-pip
  6. r-base
  7. r-base-dev
  8. r-cran-rgl
  9. mutt
  10. git
  11. texlive-fonts-recommended
  12.  
  13. # Install requirements fot the flask app
  14. RUN pip3 install -r ./requirements.txt
  15.  
  16. @app.route('/send', methods=['POST'])
  17. def send():
  18. path = os.path.dirname(os.path.realpath(__file__))
  19. script = path + '/generate_pdf.sh'
  20. address = str(request.form['email'])
  21. start_date = convert_date(str(request.form['start_date']))
  22. end_date = convert_date(str(request.form['end_date']))
  23. command = [script, start_date, end_date, address]
  24. subprocess.run(command)
  25. return json.dumps({
  26. 'status': 'OK',
  27. 'message': 'The action is completed'
  28. })
  29.  
  30. #!/bin/bash
  31. start_date="$1"
  32. end_date="$2"
  33. address="$3"
  34. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  35. report_name=""$DIR/my_document.pdf""
  36. R -e "rmarkdown::render('$DIR/generate_document.Rmd', output_file = $report_name)" --args "$start_date" "$end_date"
  37. report_name="$DIR/my_document.pdf"
  38. echo | mutt -s "Generated document" -a $report_name -- "$address"
  39. out=$(rm $report_name)
  40.  
  41. where.clause <- paste0("time >= '",
  42. start.date,
  43. "' AND time <= '",
  44. as.character(as.Date(end.date) + days(1)),
  45. "'")
  46. con <- influxdbr::influx_connection(host = "localhost",
  47. port = 8086,
  48. user = "root",
  49. pass = "root")
  50. select.query <- paste0(
  51. 'id, name, surname, car, employment_status'
  52. )
  53. rows <- influx_select(con, db = 'my_db', select.query, from = 'workers',
  54. where = where.clause)
  55. rows <- as.data.frame(rows, stringsAsFactors = FALSE)
  56. if(is.data.frame(rows) && nrow(rows) == 0) {
  57. cat('No data could be obtained from the database.', sep = 'n')
  58. knitr::knit_exit()
  59. }
  60.  
  61. ....
  62. label: unnamed-chunk-4 (with options)
  63. List of 3
  64. $ echo : logi FALSE
  65. $ message: logi FALSE
  66. $ warning: logi FALSE
  67.  
  68. Success: (204) No Content
  69. /app/generate_pdf.sh: line 8: 58 Killed
  70. ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement