-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from PanDAWMS/flin
v1.0.0, check with pylint and codeql
- Loading branch information
Showing
10 changed files
with
360 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# For most projects, this workflow file will not need changing; you simply need | ||
# to commit it to your repository. | ||
# | ||
# You may wish to alter this file to override the set of languages analyzed, | ||
# or to provide custom queries or build logic. | ||
# | ||
# ******** NOTE ******** | ||
# We have attempted to detect the languages in your repository. Please check | ||
# the `language` matrix defined below to confirm you have the correct set of | ||
# supported CodeQL languages. | ||
# | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ "master" ] | ||
schedule: | ||
- cron: '33 1 * * 2' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} | ||
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'python' ] | ||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ] | ||
# Use only 'java' to analyze code written in Java, Kotlin or both | ||
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both | ||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v2 | ||
with: | ||
languages: ${{ matrix.language }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
|
||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs | ||
# queries: security-extended,security-and-quality | ||
|
||
|
||
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). | ||
# If this step fails, then you should remove it and run the build manually (see below) | ||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v2 | ||
|
||
# ℹ️ Command-line programs to run using the OS shell. | ||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun | ||
|
||
# If the Autobuild fails above, remove it and uncomment the following three lines. | ||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. | ||
|
||
# - run: | | ||
# echo "Run, Build Application using script" | ||
# ./location_of_script_within_repo/buildscript.sh | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v2 | ||
with: | ||
category: "/language:${{matrix.language}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Pylint | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.9", "3.11"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install pylint dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pylint | ||
- name: Install code dependencies | ||
run: | | ||
pip install --upgrade htcondor | ||
- name: Analysing the code with pylint | ||
run: | | ||
pylint --fail-under=8.0 --extension-pkg-allow-list=htcondor $(git ls-files 'bin/*.py' 'lib/*.py') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
""" | ||
main executable of HGCS | ||
""" | ||
|
||
import os | ||
import sys | ||
import inspect | ||
import errno | ||
import shutil | ||
import argparse | ||
|
||
import time | ||
import re | ||
|
||
import logging | ||
|
||
# # Get main directory path | ||
|
@@ -32,38 +30,18 @@ | |
|
||
#=============================================================== | ||
|
||
def testing(): | ||
""" | ||
Test function | ||
""" | ||
# schedd = MySchedd() | ||
# for job in schedd.xquery(projection=['ClusterId', 'ProcId', 'JobStatus']): | ||
# print(repr(job)) | ||
# requirements = ( | ||
# 'JobStatus == 4 ' | ||
# '&& User == "[email protected]" ' | ||
# '&& ClusterId == 18769 ' | ||
# ) | ||
# for job in schedd.xquery(constraint=requirements): | ||
# print(job.get('ClusterId'), job.get('JobStatus'), job.get('SUBMIT_UserLog', None), job.get('ffffff', None)) | ||
# sleep_period = 300 | ||
# thread_list = [] | ||
# thread_list.append(LogRetriever(sleep_period=sleep_period)) | ||
# # thread_list.append(CleanupDelayer(sleep_period=sleep_period)) | ||
# thread_list.append(SDFFetcher(sleep_period=sleep_period)) | ||
# [ thr.start() for thr in thread_list ] | ||
pass | ||
|
||
def main(): | ||
""" | ||
Main function | ||
main function | ||
""" | ||
# command argparse | ||
oparser = argparse.ArgumentParser(prog='hgcs', add_help=True) | ||
subparsers = oparser.add_subparsers() | ||
oparser.add_argument('-c', '--config', action='store', dest='config', | ||
metavar='<file>', help='Configuration file') | ||
oparser.add_argument('-F', '--foregroudlog', action='store_true', dest='foregroudlog', | ||
# subparsers = oparser.add_subparsers() | ||
oparser.add_argument('-c', '--config', action='store', | ||
dest='config', metavar='<file>', | ||
help='Configuration file') | ||
oparser.add_argument('-F', '--foregroudlog', action='store_true', | ||
dest='foregroudlog', | ||
help='Print logs to foregroud') | ||
# start parsing | ||
if len(sys.argv) == 1: | ||
|
@@ -74,7 +52,7 @@ def main(): | |
if os.path.isfile(arguments.config): | ||
config_file_path = arguments.config | ||
else: | ||
print('Invalid configuration file: {0}'.format(arguments.config)) | ||
print(f'Invalid configuration file: {arguments.config}') | ||
sys.exit(1) | ||
# defaults | ||
log_file = '/tmp/hgcs.log' | ||
|
@@ -83,11 +61,11 @@ def main(): | |
# load config | ||
try: | ||
config = hgcs_config.ConfigClass(config_file_path) | ||
except IOError as e: | ||
print('IOError: {0}'.format(e)) | ||
except IOError as exc: | ||
print(f'IOError: {exc}') | ||
sys.exit(1) | ||
except Exception as e: | ||
print('Cannot load conifg: {0}'.format(e)) | ||
except Exception as exc: | ||
print(f'Cannot load conifg: {exc}') | ||
sys.exit(1) | ||
# handle master part of config | ||
try: | ||
|
@@ -118,19 +96,19 @@ def main(): | |
'limit': getattr(section, 'limit', None), | ||
} | ||
agent_instance = class_obj(**param_dict) | ||
utils.setupLogger(agent_instance.logger, | ||
utils.setup_logger(agent_instance.logger, | ||
pid=agent_instance.get_pid, | ||
colored=logger_format_colored, | ||
to_file=log_file) | ||
agent_instance.logger.setLevel(LOG_LEVEL_MAP.get(log_level, logging.ERROR)) | ||
logging_log_level = LOG_LEVEL_MAP.get(log_level, logging.ERROR) | ||
agent_instance.logger.setLevel(logging_log_level) | ||
thread_list.append(agent_instance) | ||
# run threads | ||
for thr in thread_list: | ||
print('Start thread of agent {0}'.format(thr.__class__.__name__)) | ||
print(f'Start thread of agent {thr.__class__.__name__}') | ||
thr.start() | ||
|
||
#=============================================================== | ||
|
||
if __name__ == '__main__': | ||
# testing() | ||
main() |
Oops, something went wrong.