{"id":40652226,"url":"https://github.com/deep-compute/basescript","last_synced_at":"2026-01-21T08:27:23.334Z","repository":{"id":46196745,"uuid":"55918428","full_name":"deep-compute/basescript","owner":"deep-compute","description":"Basic infrastructure for writing scripts in Python","archived":false,"fork":false,"pushed_at":"2023-01-07T21:50:14.000Z","size":135,"stargazers_count":9,"open_issues_count":0,"forks_count":15,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-11-27T17:26:41.943Z","etag":null,"topics":["command-line","meta","python","script"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deep-compute.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-10T19:33:48.000Z","updated_at":"2023-01-07T21:14:40.000Z","dependencies_parsed_at":"2023-02-08T02:32:35.537Z","dependency_job_id":null,"html_url":"https://github.com/deep-compute/basescript","commit_stats":null,"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/deep-compute/basescript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deep-compute%2Fbasescript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deep-compute%2Fbasescript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deep-compute%2Fbasescript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deep-compute%2Fbasescript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deep-compute","download_url":"https://codeload.github.com/deep-compute/basescript/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deep-compute%2Fbasescript/sbom","scorecard":{"id":331772,"data":{"date":"2025-08-11","repo":{"name":"github.com/deep-compute/basescript","commit":"e02582c6643b8d724829df022662a3d08633e2a7"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":7,"reason":"Found 9/12 approved changesets -- score normalized to 7","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact 0.3.6 not signed: https://api.github.com/repos/deep-compute/basescript/releases/25675319","Warn: release artifact 0.3.6 does not have provenance: https://api.github.com/repos/deep-compute/basescript/releases/25675319"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 28 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T03:48:35.293Z","repository_id":46196745,"created_at":"2025-08-18T03:48:35.293Z","updated_at":"2025-08-18T03:48:35.293Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28630273,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-21T04:47:28.174Z","status":"ssl_error","status_checked_at":"2026-01-21T04:47:22.943Z","response_time":86,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","meta","python","script"],"created_at":"2026-01-21T08:27:22.721Z","updated_at":"2026-01-21T08:27:23.327Z","avatar_url":"https://github.com/deep-compute.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Base Script\n===========\n\n[![Build Status](https://travis-ci.org/deep-compute/basescript.svg?branch=master)](https://travis-ci.org/deep-compute/basescript)\n[![PyPI version](https://badge.fury.io/py/basescript.svg)](https://badge.fury.io/py/basescript)\n\n\nPython is an excellent language that makes writing scripts very straightforward. Over the course of writing many scripts, we realized that we were doing some things over and over like creating a logger and accepting command line arguments. Base script is a very simple abstraction that takes care of setting up logging and other basics so you can focus on your application specific logic.\n\nHere are some facilities that Base Script offers:\n- Logging\n- Accepting command-line arguments using argparse\n\n## Installation\n\n``` bash\npip install basescript\n```\n\n## Usage\n\nHere is a simple example to get started\n\n### Hello World\n\nhelloworld.py\n```python\nfrom basescript import BaseScript\n\nclass HelloWorld(BaseScript):\n    def run(self):\n        print \"Hello world\"\n\nif __name__ == '__main__':\n    HelloWorld().start()\n```\n\n\u003e NOTE: all examples showcased here are available under the `examples` directory\n\nRun the above by doing:\n\n```bash\npython helloworld.py run\n```\n\nRun script with log level set to DEBUG\n\n```bash\npython helloworld.py --log-level DEBUG run\n```\n\nRun script with custom log file\n\n```bash\npython helloworld.py --log-level DEBUG --log mylog run\n```\n\n### Command line args, Using the logger\nThe following is a more involved example\n\nadder.py\n```python\nfrom basescript import BaseScript\n\nclass Adder(BaseScript):\n    # The following specifies the script description so that it be used\n    # as a part of the usage doc when --help option is used during running.\n    DESC = 'Adds numbers'\n\n    def __init__(self):\n        super(Adder, self).__init__()\n        self.a = 10\n        self.b = 20\n\n    def define_args(self, parser):\n        parser.add_argument('c', type=int, help='Number to add')\n\n    def run(self):\n        self.log.info(\"Starting run of script ...\")\n\n        print self.a + self.b + self.args.c\n\n        self.log.info(\"Script is done\")\n\nif __name__ == '__main__':\n    Adder().start()\n```\n\nRun the script as follows and observe the usage information shown. Note how the\ndescription appears along with the `c` argument.\n```bash\npython adder.py --help\nusage: adder.py [-h] [--name NAME] [--log-level LOG_LEVEL]\n                [--log-format {json,pretty}] [--log-file LOG_FILE] [--quiet]\n                [--metric-grouping-interval METRIC_GROUPING_INTERVAL]\n                [--debug]\n                {run} ...\n\nAdds numbers\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --name NAME           Name to identify this instance\n  --log-level LOG_LEVEL\n                        Logging level as picked from the logging module\n  --log-format {json,pretty}\n                        Force the format of the logs. By default, if the\n                        command is from a terminal, print colorful logs.\n                        Otherwise print json.\n  --log-file LOG_FILE   Writes logs to log file if specified, default: None\n  --quiet               if true, does not print logs to stderr, default: False\n  --metric-grouping-interval METRIC_GROUPING_INTERVAL\n                        To group metrics based on time interval ex:10 i.e;(10\n                        sec)\n  --debug               To run the code in debug mode\n\ncommands:\n  {run}\n```\n```bash\npython adder.py run --help\nusage: adder.py run [-h] c\n\npositional arguments:\n  c           Number to add\n\noptional arguments:\n  -h, --help  show this help message and exit\n```\n\nRun the script now to see the intended output\n```shell\npython adder.py run 30\n60\n```\n\nRun the same with info and higher level logs enabled\n```bash\npython adder.py --log-level INFO 30\n2016-04-10 13:48:27,356 INFO Starting run of script ...\n60\n2016-04-10 13:48:27,356 INFO Script is done\n```\n\n`--log-level` accepts all the values shown at\nhttps://docs.python.org/2/library/logging.html#logging-levels.\n\n`log` is a log object created using python's standard `logging` module. You can\nread more about it at https://docs.python.org/2/library/logging.html.\n\n#### Sub commands\nWhen we have multiple functionalities then there is a way to call or execute each functionality with different sub command.\n\nFor example if we have add and subtract in the same script then we can call each functionality with different sub command.\n\ncalc.py\n```python\nfrom basescript import BaseScript\n\nclass Calc(BaseScript):\n    A = 10\n\n    def add(self):\n        print(self.A + self.args.b)\n\n    def sub(self):\n        print(self.A - self.args.b)\n\n    def define_subcommands(self, subcommands):\n        super(Calc, self).define_subcommands(subcommands)\n\n        add_cmd = subcommands.add_parser(\"add\", help=\"Adds number\")\n        add_cmd.set_defaults(func=self.add)\n        add_cmd.add_argument('--b', type=int, help=\"Number to add\")\n\n        sub_cmd = subcommands.add_parser(\"sub\", help=\"Subtracts number\")\n        sub_cmd.set_defaults(func=self.sub)\n        sub_cmd.add_argument('--b', type=int, help=\"Number to subtract\")\n\nif __name__ == '__main__':\n    Calc().start()\n```\nRun\n```bash\n$ python3 calc.py add --b 4\n14\n$ python3 calc.py sub --b 4\n6\n```\n\n### Metric-Grouping\nWhen writing a `Metric` using `self.log`, you can specify `type=metric`. If this is done, a background thread will automatically group multiple metrics into one by averaging values (to prevent writing too many log lines).\ntest.py\n```\nfrom basescript import BaseScript\nimport time\nimport random\n\nclass Stats(BaseScript):\n    def __init__(self):\n        super(Stats, self).__init__()\n\n    def run(self):\n        ts = time.time()\n        while True:\n            # Metric Format.\n            self.log.info(\"stats\", time_duration=(time.time()-ts), type=\"metric\", random_number=random.randint(1, 50))\n\nif __name__ == '__main__':\n    Stats().start()\n```\n\nRun the command to see the output.\n```\npython test.py --metric-grouping-interval 5 run\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeep-compute%2Fbasescript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeep-compute%2Fbasescript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeep-compute%2Fbasescript/lists"}