Commit 2d3424b4 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

first commit

parents
# Python temp files
**/__pycache__/
**/*.py~
**/*.pyc
# Python virtualenv folder
**/venv/
# IDE Project files
**/.idea/
**/.vscode/
**/*.swp
# MacOS folder attributes files
**/*.DS_Store
# Files created during testingxi
/_build/
test_reports.xml
**/.cache
**/.pytest_cache/
# Compiled python modules.
**/.pyc
# Setuptools distribution folder.
/dist/
# Code coverage
**/.coverage
# log
*.log
# Python egg metadata, regenerated from source files by setuptools.
**/*.egg-info
**/*.rdb
.eggs
**/build/
**/dist/
**/_version.py
\ No newline at end of file
# Common Library for CSST DFS
## Introduction
This package provides basic common library for CSST.
## Installation
This library can be installed from sources with the following command:
```bash
python setup.py install
```
# coding: utf-8
__version_info__ = (1, 0, 0)
__version__ = '.'.join(map(str, __version_info__))
__all__ = ['logging']
\ No newline at end of file
# coding: utf-8
from .date_utils import *
\ No newline at end of file
from datetime import datetime
def format_datetime(dt):
return dt.strftime('%Y-%m-%d %H:%M:%S')
def format_date(dt):
return dt.strftime('%Y-%m-%d')
\ No newline at end of file
# coding: utf-8
from .setup import setup_logging, setup_test_logging
__all__ = ['setup_logging', 'setup_test_logging']
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019 Shoulin Wei
#
# This file is part of CSST.
# coding: utf-8
import logging
import logging.handlers
def setup_logging():
""" Setup logging configuration """
# Console formatter, mention name
cfmt = logging.Formatter(('%(name)s - %(levelname)s - %(message)s'))
# File formatter, mention time
ffmt = logging.Formatter(('%(asctime)s - %(levelname)s - %(message)s'))
# Console handler
ch = logging.StreamHandler()
ch.setLevel(logging.INFO)
ch.setFormatter(cfmt)
# File handler
fh = logging.handlers.RotatingFileHandler('csst.log',
maxBytes=10*1024*1024, backupCount=10)
fh.setLevel(logging.INFO)
fh.setFormatter(ffmt)
# Create the logger,
# adding the console and file handler
csst_logger = logging.getLogger('csst')
csst_logger.handlers = []
csst_logger.setLevel(logging.DEBUG)
csst_logger.addHandler(ch)
csst_logger.addHandler(fh)
# Set up the concurrent.futures logger
cf_logger = logging.getLogger('concurrent.futures')
cf_logger.setLevel(logging.DEBUG)
cf_logger.addHandler(ch)
cf_logger.addHandler(fh)
return csst_logger
def setup_test_logging():
# Console formatter, mention name
cfmt = logging.Formatter(('%(name)s - %(levelname)s - %(message)s'))
# File formatter, mention time
ffmt = logging.Formatter(('%(asctime)s - %(levelname)s - %(message)s'))
# Only warnings and more serious stuff on the console
ch = logging.StreamHandler()
ch.setLevel(logging.WARN)
ch.setFormatter(cfmt)
# Outputs DEBUG level logging to file
fh = logging.FileHandler('csst-test.log')
fh.setLevel(logging.DEBUG)
fh.setFormatter(ffmt)
# Set up the montblanc logger
csst_logger = logging.getLogger('csst')
csst_logger.handlers = []
csst_logger.setLevel(logging.DEBUG)
csst_logger.addHandler(ch)
csst_logger.addHandler(fh)
# Set up the concurrent.futures logger
cf_logger = logging.getLogger('concurrent.futures')
cf_logger.setLevel(logging.DEBUG)
cf_logger.addHandler(ch)
cf_logger.addHandler(fh)
return csst_logger
\ No newline at end of file
# coding: utf-8
class Result(dict):
def __init__(self):
super(Result, self).__init__()
self.code = 0
self.message = ""
self.data = None
def success(self):
return self.code >= 0
@staticmethod
def error(code = -1, message = ""):
r = Result()
r.code = code
r.message = message
return r
@staticmethod
def ok_data(data):
r = Result()
r.data = data
return r
@staticmethod
def ok_msg(message):
r = Result()
r.message = message
return r
\ No newline at end of file
[metadata]
# replace with your username:
name = csst_dfs_commons
author =CSST DFS Team.
author_email = weishoulin@astrolab.cn
description = CSST Commons Module.
long_description = file: README.md
long_description_content_type = text/markdown
keywords = astronomy, astrophysics, cosmology, space, CSST
url = https://github.com/astronomical-data-processing/csst-dfs-commons
project_urls =
Bug Tracker = https://github.com/astronomical-data-processing/csst-dfs-commons/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent
[options]
packages = find:
python_requires = >=3.7
zip_safe = False
setup_requires = setuptools_scm
install_requires =
astropy>=4.0
\ No newline at end of file
# coding: utf-8
import os
from setuptools import setup
setup(use_scm_version={'write_to': os.path.join('csst_dfs_commons', '_version.py')})
Supports Markdown
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