Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FROM ubuntu
- # Install requirements fot the flask app
- RUN apt-get clean && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y && DEBIAN_FRONTEND=noninteractive apt-get install -y
- python3
- python3-pip
- r-base
- r-base-dev
- r-cran-rgl
- mutt
- git
- texlive-fonts-recommended
- # Install requirements fot the flask app
- RUN pip3 install -r ./requirements.txt
- @app.route('/send', methods=['POST'])
- def send():
- path = os.path.dirname(os.path.realpath(__file__))
- script = path + '/generate_pdf.sh'
- address = str(request.form['email'])
- start_date = convert_date(str(request.form['start_date']))
- end_date = convert_date(str(request.form['end_date']))
- command = [script, start_date, end_date, address]
- subprocess.run(command)
- return json.dumps({
- 'status': 'OK',
- 'message': 'The action is completed'
- })
- #!/bin/bash
- start_date="$1"
- end_date="$2"
- address="$3"
- DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
- report_name=""$DIR/my_document.pdf""
- R -e "rmarkdown::render('$DIR/generate_document.Rmd', output_file = $report_name)" --args "$start_date" "$end_date"
- report_name="$DIR/my_document.pdf"
- echo | mutt -s "Generated document" -a $report_name -- "$address"
- out=$(rm $report_name)
- where.clause <- paste0("time >= '",
- start.date,
- "' AND time <= '",
- as.character(as.Date(end.date) + days(1)),
- "'")
- con <- influxdbr::influx_connection(host = "localhost",
- port = 8086,
- user = "root",
- pass = "root")
- select.query <- paste0(
- 'id, name, surname, car, employment_status'
- )
- rows <- influx_select(con, db = 'my_db', select.query, from = 'workers',
- where = where.clause)
- rows <- as.data.frame(rows, stringsAsFactors = FALSE)
- if(is.data.frame(rows) && nrow(rows) == 0) {
- cat('No data could be obtained from the database.', sep = 'n')
- knitr::knit_exit()
- }
- ....
- label: unnamed-chunk-4 (with options)
- List of 3
- $ echo : logi FALSE
- $ message: logi FALSE
- $ warning: logi FALSE
- Success: (204) No Content
- /app/generate_pdf.sh: line 8: 58 Killed
- ....
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement