mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
slack importer: Fix output_dir path and remove sys.exit(0).
Also, as the exception is being handled in 'slack_data_to_zulip_data' remove it from the manage.py command 'convert_slack_data'.
This commit is contained in:
@@ -600,6 +600,12 @@ def do_convert_data(slack_zip_file: str, realm_subdomain: str, output_dir: str,
|
||||
slack_data_dir = slack_zip_file.replace('.zip', '')
|
||||
if not os.path.exists(slack_data_dir):
|
||||
os.makedirs(slack_data_dir)
|
||||
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
# output directory should be empty initially
|
||||
if os.listdir(output_dir):
|
||||
raise Exception('Output directory should be empty!')
|
||||
|
||||
subprocess.check_call(['unzip', '-q', slack_zip_file, '-d', slack_data_dir])
|
||||
# with zipfile.ZipFile(slack_zip_file, 'r') as zip_ref:
|
||||
# zip_ref.extractall(slack_data_dir)
|
||||
@@ -639,7 +645,6 @@ def do_convert_data(slack_zip_file: str, realm_subdomain: str, output_dir: str,
|
||||
|
||||
logging.info('######### DATA CONVERSION FINISHED #########\n')
|
||||
logging.info("Zulip data dump created at %s" % (output_dir))
|
||||
sys.exit(0)
|
||||
|
||||
def get_data_file(path: str) -> Any:
|
||||
data = json.load(open(path))
|
||||
|
||||
@@ -35,9 +35,6 @@ class Command(BaseCommand):
|
||||
output_dir = tempfile.mkdtemp(prefix="/tmp/converted-slack-data-")
|
||||
else:
|
||||
output_dir = os.path.realpath(output_dir)
|
||||
if os.path.exists(output_dir):
|
||||
shutil.rmtree(output_dir)
|
||||
os.makedirs(output_dir)
|
||||
|
||||
realm_name = options['realm_name']
|
||||
token = options['token']
|
||||
|
||||
Reference in New Issue
Block a user