I have just finished writing a utility to copy files to an S3 bucket, which
I based on ftpupload.py in the weevil directory.
This is now working perfectly when I call it with hard coded values, but
when I add the code at the bottom to get the variables from weewx.conf I
get the following error
$ python3 s3upload.py /Users/Mike/WebSites/Weewx/new
Traceback (most recent call last):
File "s3upload.py", line 145, in <module>
import weewx
ModuleNotFoundError: No module named 'weewx' .
The code I have used is based on the code in the ftpupload file
if __name__ == '__main__':
import configobj
import weewx
import weeutil.logger
weewx.debug = 1
weeutil.logger.setup('S3upload', {})
if len(sys.argv) < 2:
print("""Usage: s3upload.py path-to-configuration-file
[path-to-be-ftp'd]""")
sys.exit(weewx.CMD_ERROR)
try:
config_dict = configobj.ConfigObj(sys.argv[1], file_error=True,
encoding='utf-8')
except IOError:
print("Unable to open configuration file %s" % sys.argv[1])
raise
if len(sys.argv) == 2:
try:
S3_dir = os.path.join(config_dict['WEEWX_ROOT'],
config_dict['StdReport']['HTML_ROOT'])
except KeyError:
print("No HTML_ROOT in configuration dictionary.")
sys.exit(1)
else:
S3_dir = sys.argv[2]
S3_upload = S3Upload(config_dict['StdReport']['AWSCLI']['S3_BUCKET'],
config_dict['StdReport']['AWSCLI']['AWS_Profile'],
S3_dir,
config_dict['StdReport']['AWSCLI']['S3_ROOT'],
'S3')
S3_upload.run()
Any ideas
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/weewx-user/59db603b-6f76-485b-b772-38a88fda9dea%40googlegroups.com.