~jstys-z/helioviewer.org/client5

« back to all changes in this revision

Viewing changes to install/downloader.py

  • Committer: Keith Hughitt
  • Date: 2012-04-23 18:45:32 UTC
  • mto: This revision was merged to the branch mainline in revision 732.
  • Revision ID: keith.hughitt@nasa.gov-20120423184532-qwf3dvx7t1gojrdc
Unified logging for installer, updater, and downloader

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import logging
23
23
import argparse
24
24
import ConfigParser
 
25
from shared.util import init_logger
25
26
from hvpull.net.daemon import ImageRetrievalDaemon
26
27
 
27
28
def main():
119
120
            print i
120
121
        sys.exit()
121
122
 
122
 
def init_logger(filepath):
123
 
    """Initializes logging"""
124
 
    # Check for logging directory
125
 
    directory, filename = os.path.split(os.path.expanduser(filepath))
126
 
    
127
 
    if not os.path.exists(directory):
128
 
        os.makedirs(directory)
129
 
        
130
 
    os.chdir(directory)
131
 
        
132
 
    # TODO: Rotate logs
133
 
    # e.g. Move previous log to hvpull.log.1, hvpull.log.1 to hvpull.log.2, etc
134
 
    # and delete any logs greater than 10.    
135
 
    logging.basicConfig(filename=filename, level=logging.INFO,
136
 
                        format='%(asctime)s.%(msecs)03d [%(levelname)s] %(message)s',
137
 
                        datefmt='%Y-%m-%d %H:%M:%S')
138
 
    
139
 
    # Also log INFO or higher messages to STDOUT
140
 
    console = logging.StreamHandler()
141
 
    console.setLevel(logging.INFO)
142
 
    logging.getLogger('').addHandler(console)
143
 
    
144
123
def print_help(parser):
145
124
    """Prints help information for HVPull"""
146
125
    parser.print_help()