Skip to content

Commit

Permalink
Rename config to '.packj.yaml' for consistent usage
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Bijlani <[email protected]>
  • Loading branch information
ashishbijlani committed Oct 18, 2022
1 parent 256a3fe commit 764406d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 28 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
**/__pycache__
**/.DS_Store
**/.*.swp
**/.packj.yaml
**/sandbox/strace
**/sandbox/*.so
File renamed without changes.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include packj/config.yaml
include packj/.packj.yaml
include packj/audit/config/astgen_javascript_smt.config
include packj/audit/config/astgen_python_smt.config
include packj/audit/config/astgen_ruby_smt.config
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import re
import sys
from packj.main import main_wrapper
from packj.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main_wrapper())
sys.exit(main())
14 changes: 3 additions & 11 deletions packj/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
print('\n*** WARNING *** Please use Python 3! Exiting.')
exit(1)

def main(config:str):
def main(config:str='.packj.yaml'):
try:
# parse command line args
from packj.options import Options
Expand All @@ -21,6 +21,8 @@ def main(config:str):
assert args, 'Failed to get cmdline args!'

# configuration file
if not os.path.exists(config):
config = os.path.expanduser(os.path.join('~', f'{config}'))
assert os.path.exists(config), f'No {config} file found'

# audit request
Expand All @@ -36,13 +38,3 @@ def main(config:str):
except Exception as e:
print(str(e))
exit(1)

def bin_wrapper():
config = '.packj.yaml'
if not os.path.exists(config):
config = os.path.expanduser(os.path.join('~', os.path.join('.packj', 'config.yaml')))
return main(config)

def main_wrapper():
config = os.path.join(os.path.dirname(__file__), 'config.yaml')
return main(config)
26 changes: 13 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@ def setup_sandbox(build_dir):
if make_process.returncode:
raise Exception(f'Failed to install sandbox:\n{stderr}')

def copy_config():
src_path = os.path.join('packj', 'config.yaml')
dst_path = os.path.expanduser(os.path.join('~', f'.{src_path}'))
def copy_config(config='.packj.yaml'):
path = os.path.expanduser(os.path.join('~', f'{config}'))
try:
shutil.rmtree(os.path.dirname(dst_path))
os.remove(path)
except:
pass
os.mkdir(os.path.dirname(dst_path))
shutil.copy(src_path, dst_path)
shutil.copy(config, path)

def remove_config():
dst_path = os.path.expanduser(os.path.join('~', '.packj'))
if os.path.exists(dst_path):
shutil.rmtree(dst_path)
def remove_config(config='.packj.yaml'):
path = os.path.expanduser(os.path.join('~', f'{config}'))
try:
os.remove(path)
except:
pass

class custom_install(install):
def run(self):
Expand All @@ -76,9 +76,9 @@ def run(self):
'packj.audit.proto' : ['ruby/*.rb'],
},
data_files = [
(os.path.expanduser(os.path.join('~','.packj')), ['packj/config.yaml']),
(os.path.expanduser(os.path.join('~','.packj.yaml')), ['.packj.yaml']),
],
version = '0.10',
version = '0.11',
license='GNU AGPLv3',
description = 'Packj flags "risky" open-source packages in your software supply chain',
long_description=long_description,
Expand All @@ -96,7 +96,7 @@ def run(self):
requires_dist=REQUIREMENTS,
entry_points = {
'console_scripts': [
'packj=packj.main:bin_wrapper',
'packj=packj.main:main',
],
},
cmdclass = {
Expand Down

0 comments on commit 764406d

Please sign in to comment.