Skip to content

Commit

Permalink
Added missing filter for packaging a submission
Browse files Browse the repository at this point in the history
  • Loading branch information
abbyssoul committed Dec 14, 2020
1 parent 828ed80 commit 6ed13dc
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion coderone/dungeon/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,61 @@
# BASE_URL = 'http://localhost:5001/psyched-equator-297906/us-central1'


exclude_names = [
"__pycache__",
"build",
"develop-eggs",
"dist",
"downloads",
"eggs",
".eggs",
"lib",
"lib64",
"parts"
"sdist",
"var",
"wheels",
"python-wheels",
".egg-info",
".pybuilder",
"target",
".ipynb_checkpoints",
"__pypackages__",

".env",
".venv",
"env",
"venv",
"ENV",
".pyre",
".pytype",
"cython_debug"
]

exclude_ext = [
".tmp",
".pyc", ".pyo", ".pyd",
".class",
".so",
".egg-info",
".egg",
".manifest",
".spec",
".cover",
".log",
]


def filter_function(tarinfo):
if tarinfo.name in exclude_names:
return None

if os.path.splitext(tarinfo.name)[1] in exclude_names:
return None

return tarinfo


class AuthInfo(NamedTuple):
user_email:str
token:str
Expand Down Expand Up @@ -119,7 +174,7 @@ def submit(agent_module:str, single:bool, source_file:str):

with tempfile.NamedTemporaryFile(suffix='.tar.gz') as f:
with tarfile.open(fileobj=f, mode='w:gz') as tar:
tar.add(source_file, arcname=os.path.basename(source_file))
tar.add(source_file, arcname=os.path.basename(source_file), filter=filter_function)

f.flush()
f.seek(0)
Expand Down

0 comments on commit 6ed13dc

Please sign in to comment.