Problems with Github Patch.

Hello

i have a Problem with a Patch for https://github.com/Tafkas/solarpi

Well the Programm code are updated. It gave a error:

:~/solarpi_venv/solarpi$ git apply solarpi.patch
solarpi.patch:148: trailing whitespace.

error: patch failed: solarpi/app.py:30
error: solarpi/app.py: patch does not apply
error: patch failed: solarpi/public/views.py:65
error: solarpi/public/views.py: patch does not apply
solarpi.patch:148: new blank line at EOF.

With the old version of the Project it runs.

The user that write the Patch say : “I recommend using the latest version of the repository. But if the
patches don’t apply cleanly, or you have other problems, use this command”
to check out the exact commit that I used.
> git checkout 23aa8c4

------------- snip -------------
diff --git a/manage.py b/manage.py
index c6ef12d..feb40d4 100644
--- a/manage.py
+++ b/manage.py
@@ -33,7 +33,7 @@ def test():
     sys.exit(status)


-manager.add_command('server', Server())
+manager.add_command('server', Server(host='0.0.0.0'))
 manager.add_command('shell', Shell(make_context=_make_context))
 manager.add_command('db', MigrateCommand)

diff --git a/migrations/alembic.ini b/migrations/alembic.ini
index f8ed480..2c1234e 100644
--- a/migrations/alembic.ini
+++ b/migrations/alembic.ini
@@ -7,6 +7,7 @@
 # set to 'true' to run the environment during
 # the 'revision' command, regardless of autogenerate
 # revision_environment = false
+Sqlalchemy.url = sqlite:///dev.db


 # Logging configuration
diff --git a/solarpi/app.py b/solarpi/app.py
index 31d4298..2f5ecf0 100644
--- a/solarpi/app.py
+++ b/solarpi/app.py
@@ -30,7 +30,7 @@ def register_extensions(app):
     db.init_app(app)
     debug_toolbar.init_app(app)
     migrate.init_app(app, db)
- sentry.init_app(app, dsn=ProdConfig.SENTRY_DNS, logging=True, level=logging.ERROR)
+ sentry.init_app(app, dsn=None, logging=True, level=logging.ERROR)
     return None


diff --git a/solarpi/charts/helper.py b/solarpi/charts/helper.py
index 2fc9d91..a13deb5 100644
--- a/solarpi/charts/helper.py
+++ b/solarpi/charts/helper.py
@@ -3,7 +3,7 @@ from datetime import datetime


 def get_timestamps(series):
- return [1000 * (calendar.timegm(datetime.strptime(d.created_at.split(".")[0], "%Y-%m-%dT%H:%M:%S")
+ return [1000.0 * (calendar.timegm(datetime.strptime(d.created_at.split(".")[0], "%Y-%m-%dT%H:%M:%S")
                                     .replace(second=0).timetuple()))
             for d in series]

diff --git a/solarpi/charts/views.py b/solarpi/charts/views.py
index 338419e..5cb27ed 100644
--- a/solarpi/charts/views.py
+++ b/solarpi/charts/views.py
@@ -47,7 +47,7 @@ def daily(date=None):
     # get maxium photovoltaic data for ± 3 days
     pv_max = get_7_day_max_energy_series(current_date)
     current_date_midnight = calendar.timegm(current_date.timetuple())
- timestamps_pv_max = [1000 * (get_sec(d.pvdata_created_at) + current_date_midnight) for d in pv_max]
+ timestamps_pv_max = [1000.0 * (get_sec(d.pvdata_created_at) + current_date_midnight) for d in pv_max]
     daily_chart_max_data = [list(x) for x in zip(timestamps_pv_max, [(int(d.pv_max or 0)) for d in pv_max])]

     # additional data
diff --git a/solarpi/public/views.py b/solarpi/public/views.py
index 26c4937..f628261 100644
--- a/solarpi/public/views.py
+++ b/solarpi/public/views.py
@@ -53,10 +53,15 @@ def home():
     # electricity im- and export

     total_electricity = get_total_electricity()
- total_import = total_electricity.meter_180
- total_export = total_electricity.meter_280
     last_year_export = get_last_year_export()
- current_year_export = total_export - last_year_export.meter_280
+ if total_electricity is not None:
+ total_import = total_electricity.meter_180
+ total_export = total_electricity.meter_280
+ current_year_export = total_export - last_year_export.meter_280
+ else:
+ total_import = 0
+ total_export = 0
+ current_year_export = total_export

     todays_import, todays_export = 0.0, 0.0
     todays_electricity = get_todays_electricity()
@@ -65,12 +70,21 @@ def home():
         todays_export = todays_electricity.todays_export

     last_year_energy = get_last_years_energy()
- current_year_energy = total_energy - last_year_energy.total_energy
+ if last_year_energy is not None:
+ current_year_energy = total_energy - last_year_energy.total_energy
+ else:
+ current_year_energy = total_energy
+
+ yearly_average_data = get_yearly_average_data()
+ if yearly_average_data.rowcount > 0:
+ average_years_series = [int(x[0]) for x in yearly_average_data]
+ last_year_current_month_avg = average_years_series[now.month - 1] / calendar.monthrange(now.year, now.month)[1]
+ else:
+ average_years_series = []
+ last_year_current_month_avg = 1

- average_years_series = [int(x[0]) for x in get_yearly_average_data()]
     current_year_series = [int(x[0]) for x in get_yearly_data(datetime.now().year)]

- last_year_current_month_avg = average_years_series[now.month - 1] / calendar.monthrange(now.year, now.month)[1]
     current_month_prediction = get_current_month_prediction(current_year_series[-1], last_year_current_month_avg)

     return render_template("public/home.html",
diff --git a/solarpi/settings.py b/solarpi/settings.py
index 15b9b4c..7973048 100644
--- a/solarpi/settings.py
+++ b/solarpi/settings.py
@@ -14,7 +14,7 @@ class Config(object):
     DEBUG_TB_INTERCEPT_REDIRECTS = False
     CACHE_TYPE = 'simple' # Can be "memcached", "redis", etc.
     SQLALCHEMY_TRACK_MODIFICATIONS = False
- SENTRY_DNS = os_env['SENTRY_DNS']
+# SENTRY_DNS = os_env['SENTRY_DNS']


 class ProdConfig(Config):
diff --git a/solarpi/static/js/daily-chart.js b/solarpi/static/js/daily-chart.js
index d62bb40..ee366c2 100644
--- a/solarpi/static/js/daily-chart.js
+++ b/solarpi/static/js/daily-chart.js
@@ -1,5 +1,11 @@
 $(document).ready(function () {
     $(function () {
+ Highcharts.setOptions({
+ global: {
+ useUTC: false,
+ timezone: 'America/New_York'
+ }
+ });
         $('#daily-chart').highcharts({
             chart: {
                 type: 'column'
@@ -46,4 +52,4 @@ $(document).ready(function () {
         });
     });
 });
-
\ No newline at end of file
+
diff --git a/solarpi/weather/views.py b/solarpi/weather/views.py
index 9ee3693..62e677b 100644
--- a/solarpi/weather/views.py
+++ b/solarpi/weather/views.py
@@ -23,7 +23,7 @@ def daily(date=datetime.now().strftime('%Y-%m-%d')):
         Weather.created_at < tomorrow.strftime('%Y-%m-%d')).all()

     timestamps_w = [
- 1000 * calendar.timegm(datetime.strptime(d.created_at.split(".")[0], "%Y-%m-%dT%H:%M:%S").timetuple())
+ 1000.0 * calendar.timegm(datetime.strptime(d.created_at.split(".")[0], "%Y-%m-%dT%H:%M:%S").timetuple())
         for d in w]
     series_w = [(int(d.temp or 0)) for d in w]
     daily_chart_data = [list(x) for x in zip(timestamps_w, series_w)]
------------- snip -------------

Hi @rothlive,

It sounds like you’re looking for help with a specific project hosted on GitHub. While it’s definitely possible another GitHub user might have run into this same issue and can help, the GitHub Community Forum focuses primarily on topics related to GitHub itself or collaboration on project development and ideas. We want to make sure you’re getting the best support you can, but this forum may not be the right place for this particular topic.

I’d recommend checking the project’s README for instructions on how to best get support; a lot of projects will have you submit issues to their repo or provide email addresses for contact.

Best of luck!

Andrea