BrianMitchL / weatherBot

⛈ A Twitter bot for weather

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: You need to pass in the path of the conf file. Try again.

tomlear opened this issue · comments

I keep on getting this when running weatherBot.py: You need to pass in the path of the conf file. Try again.

Are you running it with a conf file as an argument? It should look something like this:

python3 weatherBot.py configuration.conf

Sorry not sure what you mean?

How are you invoking weatherBot? It's designed to be run from a command line.

Ahhhh okay:

Toms-MacBook-Pro:weatherBot-master Tom$ python3 weatherBot.py configuration.conf
Traceback (most recent call last):
  File "weatherBot.py", line 413, in <module>
    main(sys.argv[1])
  File "weatherBot.py", line 363, in main
    load_config(os.path.abspath(path))
  File "weatherBot.py", line 50, in load_config
    'dm_errors': conf['basic'].getboolean('dm_errors', True),
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/configparser.py", line 956, in __getitem__
    raise KeyError(key)
KeyError: 'basic'

Just need to sort these errors out.

What does your conf file look like? The key error means that there's no "basic" section (the [basic] header in the conf file). I will add exception handling so you can use a conf file with missing headers in the near-ish future.

# weatherBot.conf
# all fields are optional and will fallback to their default values if not given
# the default values are shown for each setting in their respective commented out line

# boolean values must be 'yes'/'no', 'on'/'off', or '1'/'0'
# quotations are only needed if a space is desired at the beginning or end of a string


[basic]
# send crash logs as a direct message to the Twitter account owning the app
;dm_errors = yes
# Choose from 'us', 'ca', 'uk2', 'si', or 'auto'
# 'auto' will automatically select units based on geographic location
;units = us
# include location in tweet (Twitter location)
;tweet_location = yes
# string of text appended to every tweet. If no hashtag is desired, set it to be blank
;hashtag = #MorrisWeather
# time in minutes to check for new weather (note, watch out for API rate limiting and costs per API call)
;refresh = 3
# YAML file with strings
;strings = strings.yml

[scheduled times]
# the time for a daily forecast to be tweeted
;forecast = 6:00
# times that a scheduled current condition tweet will be sent
# all times are local to the timezone found from the coordinates used for location
# this will only be as accurate as the refresh time,
# a tweet will be sent between the specified time and the specified time + refresh time
;conditions = 7:00
;        12:00
;        15:00
;        18:00
;        22:00
# use the following if you do not want scheduled tweets
;conditions =

[default location]
# Used for location, or fallback location
;lat = 45.585
;lng = -95.91
;name = Morris, MN

[variable location]
;enabled = no
;user = bman4789

[log]
# write log to file
;enabled = yes
# path to log file, ignored if disabled
# Note that while ~/weatherBot.log is the default, you cannot use the ~ character here
;log_path = ~/weatherBot.log

[throttles]
# time in minutes to throttle each event type
;default = 120
;wind-chill = 120
;medium-wind = 180
;heavy-wind = 120
;fog = 180
;cold = 120
;hot = 120
;dry = 120
;heavy-rain = 60
;moderate-rain = 60
;light-rain = 90
;very-light-rain = 120
;heavy-snow = 60
;moderate-snow = 60
;light-snow = 90
;very-light-snow = 120
;heavy-sleet = 45
;moderate-sleet = 60
;light-sleet = 90
;very-light-sleet = 120
;heavy-hail = 15
;moderate-hail = 15
;light-hail = 20
;very-light-hail = 30

Hmm, strange, that looks fine to me. I'm assuming this is all using the latest version of the repo and the files haven't been modified at all, is that correct?

Correct apart from keys.py

You need to pass in a path to a configuration file that exists. The default one is weatherBot.conf. In my comment above, I used configuration.conf as an example, but that does not exist within the project, unless you added it.

v2.1 was just released which will alert a user if the configuration file does not exist.