1
0
mirror of https://github.com/gryf/slack-backup.git synced 2025-12-17 19:40:21 +01:00

Added new option - url_file_to_attachement

Currently, if message contain shared file, slack-backup will try to
download it. If it fail, than empty file will remain, which will be at
least confusing. This will mostly happen for shares which are not
uploaded to the slack servers.

New option will be used to indicate if slack-backup should convert such
share as an attachment, or to save the list of URL and their
destination in local file system to be download manually by the user.
This commit is contained in:
2018-05-22 22:10:34 +02:00
parent 007fe04c08
commit 71355b1c4a
3 changed files with 20 additions and 12 deletions

View File

@@ -90,13 +90,17 @@ def main():
fetch.add_argument('-c', '--channels', default=None, nargs='+',
help='List of channels to perform actions on. '
'Default is all channels.')
fetch.add_argument('-d', '--database', default=None,
help='Path to the database file.')
fetch.add_argument('-i', '--config', default=None,
help='Use specific config file.')
fetch.add_argument('-f', '--url_file_to_attachement', default=False,
action='store_true',
help='Treat shared files (but not uploaded to the '
'Slack servers) as attachement. By default there will '
'be file created in current directory with url and '
'path to the filename under which it would be '
'registered in the DB.')
fetch.set_defaults(func=fetch_data)
generate = subparser.add_parser('generate', help='Generate logs out of '
@@ -113,7 +117,6 @@ def main():
choices=('plain', 'unicode'),
help='Choose theme for text output. It doesn\'t '
'affect other output formats.')
generate.add_argument('-v', '--verbose', help='Be verbose. Adding more '
'"v" will increase verbosity', action="count",
default=None)
@@ -123,13 +126,10 @@ def main():
generate.add_argument('-c', '--channels', default=[], nargs='+',
help='List of channels to perform actions on. '
'Default is all channels.')
generate.add_argument('-d', '--database', default=None,
help='Path to the database file.')
generate.add_argument('-i', '--config', default=None,
help='Use specific config file.')
generate.set_defaults(func=generate_raport)
args = parser.parse_args()

View File

@@ -13,8 +13,10 @@ class Config(object):
"""Configuration keeper"""
ints = ['verbose', 'quiet']
bools = ['url_file_to_attachement']
sections = {'common': ['channels', 'database', 'quiet', 'verbose'],
sections = {'common': ['channels', 'database', 'quiet', 'verbose',
'url_file_to_attachement'],
'fetch': ['user', 'password', 'team', 'token'],
'generate': ['output', 'format', 'theme']}
@@ -35,7 +37,8 @@ class Config(object):
'token': None,
'output': None,
'format': None,
'theme': None}
'theme': None,
'url_file_to_attachement': False}
# This message supposed to be displayed in INFO level. During the time
# of running the code where it should be displayed there is no
# complete information about logging level. Displaying message is
@@ -79,6 +82,8 @@ class Config(object):
for option in self.sections[section]:
if option in self.ints:
val = self.cp.getint(section, option, fallback=0)
elif option in self.bools:
val = self.cp.getboolean(section, option, fallback=False)
elif option == 'channels':
val = self.cp.get(section, option, fallback='[]')
val = json.loads(val)

View File

@@ -63,7 +63,8 @@ class TestConfig(unittest.TestCase):
'user': None,
'password': None,
'team': None,
'token': None})
'token': None,
'url_file_to_attachement': False})
args = argparse.Namespace()
args.config = self.confname
@@ -97,7 +98,8 @@ class TestConfig(unittest.TestCase):
'team': 'myteam',
'token': 'xxxx-1111111111-'
'222222222222-333333333333-'
'r4nd0ms7uff'})
'r4nd0ms7uff',
'url_file_to_attachement': False})
# override some conf options with commandline
args = argparse.Namespace()
@@ -124,4 +126,5 @@ class TestConfig(unittest.TestCase):
'user': 'joe',
'password': 'ultricies',
'team': '',
'token': 'the token'})
'token': 'the token',
'url_file_to_attachement': False})