Commit 9f4d2d00 authored by Rob Carleski's avatar Rob Carleski 🇮🇸
Browse files

Specify that ID is needed for custom root folder.

* Additionally, skip unorganized and shared runs for custom root runs
parent 70ffa4eb
......@@ -54,7 +54,7 @@ class Sifter:
self.private_files = {}
self.unknown_files = {}
self.shared_files = {}
self.parent = [self.root_folder]
self.parent = [self.root_folder_id]
def sift(self, folder_id, in_private=False):
self.logger.info(
......@@ -145,8 +145,7 @@ class Sifter:
'owner': item['owners.0.emailAddress'],
'name': item['title'],
'id': item['id'],
'link': item['alternateLink'],
'parent': self.root_folder
'link': item['alternateLink']
}
except CalledProcessError as e:
self.logger.error(e.output, extra={'entity': self.account})
......@@ -314,9 +313,9 @@ def main():
required=True
)
parser.add_argument(
'--root_folder',
'--root_folder_id',
'-r',
help='Use a particular folder as root.',
help='The ID of the folder to use as root.',
default='root'
)
parser.add_argument(
......@@ -381,9 +380,10 @@ def main():
logger.addHandler(ch)
sifter = Sifter(vars(args), config)
sifter.sift(args.root_folder)
sifter.find_unorganized()
sifter.find_shared()
sifter.sift(args.root_folder_id)
if args.root_folder_id == 'root':
sifter.find_unorganized()
sifter.find_shared()
sifter.scrub_duplicates()
sifter.write_logfiles()
if args.skip_upload:
......
......@@ -21,7 +21,7 @@ def test_sift(mock_login):
args = {
'account': 'user1',
'destination_account': 'testuser',
'root_folder': 'root'
'root_folder_id': 'root'
}
sifter = sift_drive.Sifter(
args,
......@@ -51,7 +51,7 @@ def test_sift_ignore_ownership(mock_login):
args = {
'account': 'user1',
'destination_account': 'testuser',
'root_folder': 'root',
'root_folder_id': 'root',
'ignore_owner': True
}
sifter = sift_drive.Sifter(
......@@ -75,13 +75,13 @@ def test_sift_with_specified_root(mock_login):
mock_login.return_value('testuser')
args = {
'account': 'testuser',
'root_folder': 'different_root'
'root_folder_id': 'different_root'
}
sifter = sift_drive.Sifter(
args,
yaml.load(open(config), Loader=yaml.BaseLoader)
)
if sifter.root_folder != 'different_root':
if sifter.root_folder_id != 'different_root':
assert False
......@@ -91,7 +91,7 @@ def test_sift_skip_upload(mock_login):
args = {
'account': 'testuser',
'destination_account': False,
'root_folder': 'root'
'root_folder_id': 'root'
}
sifter = sift_drive.Sifter(
args,
......@@ -113,7 +113,7 @@ def test_sift_extra_omits(mock_login):
args = {
'account': 'testuser',
'omit_folders': ['private1', 'private2'],
'root_folder': 'root'
'root_folder_id': 'root'
}
sifter = sift_drive.Sifter(
args,
......@@ -129,7 +129,7 @@ def test_sift_with_good_specified_destination(mock_login):
args = {
'account': 'testuser',
'destination_account': 'testuser',
'root_folder': 'root'
'root_folder_id': 'root'
}
sifter = sift_drive.Sifter(
args,
......@@ -149,7 +149,7 @@ def test_empty_sift(mock_login):
args = {
'account': 'testuser',
'destination_account': 'testuser',
'root_folder': 'root'
'root_folder_id': 'root'
}
sifter = sift_drive.Sifter(
args,
......@@ -169,7 +169,7 @@ def test_sift_with_bad_account(mock_login):
with pytest.raises(SystemExit):
args = {
'account': 'notauser',
'root_folder': 'root'
'root_folder_id': 'root'
}
sifter = sift_drive.Sifter(
args,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment