ohld / igbot

🐙 Free scripts, bots and Python API wrapper. Get free followers with our auto like, auto follow and other scripts!
https://hikerapi.com/p/N2P6iqiM
Apache License 2.0
4.69k stars 1.47k forks source link

Default log file location should be configurable #833

Closed DhruvRaiPuri closed 5 years ago

DhruvRaiPuri commented 5 years ago

Please follow the guide below


Before submitting an issue, make sure you have:

Purpose of your issue?


The following sections requests more details for particular types of issues, you can remove any section (the contents between the triple ---) not applicable to your issue.


For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.

Paste the output of python -V here: Python 3.7.1 (refer - https://cloud.google.com/functions/docs/concepts/python-runtime) Code:

# Example code that will produce the error reported
from instabot import Bot
bot = Bot()

Error/Debug Log:

Traceback (most recent call last): File "/env/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 349, in run_background_function _function_handler.invoke_user_function(event_object) File "/env/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 215, in invoke_user_function return call_user_function(request_or_event) File "/env/lib/python3.7/site-packages/google/cloud/functions/worker.py", line 212, in call_user_function event_context.Context(**request_or_event.context)) File "/user_code/main.py", line 27, in loadInstaFeedToBigQuery bot = Bot() File "/env/lib/python3.7/site-packages/instabot/bot/bot.py", line 97, in __init__ self.api = API(device=device) File "/env/lib/python3.7/site-packages/instabot/api/api.py", line 43, in __init__ fh = logging.FileHandler(filename='instabot.log') File "/opt/python3.7/lib/python3.7/logging/__init__.py", line 1092, in __init__ StreamHandler.__init__(self, self._open()) File "/opt/python3.7/lib/python3.7/logging/__init__.py", line 1121, in _open return open(self.baseFilename, self.mode, encoding=self.encoding) OSError: [Errno 30] Read-only file system: '/user_code/instabot.log'

Describe your issue

I am running instabot in Python Google Cloud Function environment. The default folder in which the code runs (/user_code) is read-only.

The code in api.py which instantiates FileHandler for logger is harcoded in the package to 'instabot.log' due to which a read-only error is thrown by Cloud Function runtime as it attempts to write to '/user_code/instabot.log' which it can't.

There should be a way to override the log file location to a different folder (in this case '/user_code/tmp' where 'tmp' is the only folder with write permission in a Google Cloud Function).

ohld commented 5 years ago

Agreed. Can you please code this and make a pull request?

DhruvRaiPuri commented 5 years ago

Sure, will work on it and submit a pull request.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.