From a6a6febe5fdcf8eaf787436640e1d261e6d87bc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Sat, 28 Mar 2020 16:55:34 +0100 Subject: [PATCH] :rocket: Added Pipeline File --- Analyser.py | 30 ++++++++++++++++++++++++++---- HttpRequestHandler.py | 12 ++++++++++++ Main.py | 4 ++-- bitbucket-pipelines.yml | 31 +++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 HttpRequestHandler.py create mode 100644 bitbucket-pipelines.yml diff --git a/Analyser.py b/Analyser.py index db08c31..f295092 100644 --- a/Analyser.py +++ b/Analyser.py @@ -22,22 +22,44 @@ geoId countryterritoryCode popData2018 """ +from datetime import datetime, timedelta class Analyser: # Pandas Settings - pd.set_option('display.max_row', 1000) + pd.set_option('display.max_row', 50) pd.set_option('display.max_column', 10) df = pd.read_csv('2020-03-28_11-00.csv', encoding='windows-1252') df['dateRep'] = pd.to_datetime(df['dateRep']) + print(df['dateRep'].head()) def getAvailableCountries(self): return self.df['countriesAndTerritories'].unique() - def germany_cases_graph(self): + def getCasesGraph(self, country) -> str: + """ + Get a graph with the absolute number of cases by day for the entered country + :param country: The country you wish to get the graph for + :return: The path for the picture of the graph + """ fig = plt.figure() ax = fig.add_subplot(111) - germanyData = self.df[self.df['countriesAndTerritories'].isin(['Germany'])] - print(germanyData) + countryData = self.df[self.df['countriesAndTerritories'].isin([country])] + print(countryData['cases'].sum()) + + return 'abc' + + def getTotalCases(self, country, date=datetime.now().strftime('%Y-%m-%d')) -> int: + """ + Get the current total cases for the entered country + :param country: The country you want the case number for + :param date: The date for which the case number is returned. Standard is the current date. + :return: The case number + """ + countryData = self.df[self.df['countriesAndTerritories'].isin([country])] + finalData = pd.DataFrame + countryData.filter(datetime.strptime(country)) + print(finalData) + return countryData['cases'].sum() diff --git a/HttpRequestHandler.py b/HttpRequestHandler.py new file mode 100644 index 0000000..e8a47f0 --- /dev/null +++ b/HttpRequestHandler.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +""" +Project: Analyse worldwide COVID-19 Data and provide graphs etc. + +@author Patrick Müller +""" +import socketserver +from http.server import BaseHTTPRequestHandler + +class HttpRequestHandler(BaseHTTPRequestHandler): + def do_GET(self): + print('hello') \ No newline at end of file diff --git a/Main.py b/Main.py index 933491e..fdc32e1 100644 --- a/Main.py +++ b/Main.py @@ -9,5 +9,5 @@ import Analyser as ana if __name__ == '__main__': analyser = ana.Analyser() - analyser.germany_cases_graph() - print(analyser.getAvailableCountries()) + country = input('What country do you want the graph for: ') + analyser.getTotalCases(country, '2020-03-27') diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml new file mode 100644 index 0000000..29957a5 --- /dev/null +++ b/bitbucket-pipelines.yml @@ -0,0 +1,31 @@ +# This is a sample build configuration for Other. +# Check our guides at https://confluence.atlassian.com/x/5Q4SMw for more examples. +# Only use spaces to indent your .yml configuration. +# -----asd +# You can specify a custom docker image from Docker Hub as your build environment. +image: atlassian/default-image:2 + +pipelines: + branches: + master: + - step: + deployment: production + script: + - echo "Running deployment to production" + - pipe: atlassian/sftp-deploy:0.5.2 + variables: + USER: $SFTP_Username + SERVER: $SFTP_Host_Path + REMOTE_PATH: $SFTP_Production_Path + PASSWORD: $SFTP_Password +# feature: +# - step: +# deployment: test +# script: +# - echo "Running deployment to test" +# - pipe: atlassian/sftp-deploy:0.5.2 +# variables: +# USER: $SFTP_Username +# SERVER: $SFTP_Host_Path +# REMOTE_PATH: $SFTP_TestPath +# PASSWORD: $SFTP_Password