Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

''' 

rastrea2r client 

''' 

import sys 

import os 

import logging 

from logging.handlers import RotatingFileHandler 

import configparser 

 

__version__ = '0.1.0' 

 

# Initialize Configuration 

config = configparser.ConfigParser() 

config.read(os.path.join(os.path.abspath(os.path.dirname(__file__)), '../rastrea2r', 'rastrea2r.ini')) 

 

 

ENABLE_TRACE = config["rastrea2r"]["enable_trace"] 

AUTH_USER = config["rastrea2r"]["username"] 

AUTH_PASSWD = config["rastrea2r"]["password"] 

SERVER_PORT = config["rastrea2r"]["server_port"] 

CLIENT_VERSION = config["rastrea2r"]["version"] 

API_VERSION = config["rastrea2r"]["api_version"] 

 

# Check for sane config file 

25 ↛ 26line 25 didn't jump to line 26, because the condition on line 25 was never trueif "rastrea2r" not in config: 

print("Could not parse config file") 

sys.exit(1) 

 

# Logging Configuration, default level INFO 

logger = logging.getLogger("") 

logger.setLevel(logging.INFO) 

lformat = logging.Formatter("%(asctime)s %(name)s:%(levelname)s: %(message)s") 

 

# Debug mode Enabled 

35 ↛ 41line 35 didn't jump to line 41, because the condition on line 35 was never falseif "debug" in config["rastrea2r"] and int(config["rastrea2r"]["debug"]) != 0: 

debug = int(config["rastrea2r"]["debug"]) 

logger.setLevel(logging.DEBUG) 

logging.debug("Enabled Debug mode") 

else: 

# STDOUT Logging defaults to Warning 

lsh = logging.StreamHandler(sys.stdout) 

lsh.setFormatter(lformat) 

lsh.setLevel(logging.WARNING) 

logger.addHandler(lsh) 

 

# Enable logging to file if configured 

47 ↛ exitline 47 didn't exit the module, because the condition on line 47 was never falseif "logfile" in config["rastrea2r"]: 

lfh = RotatingFileHandler( 

config["rastrea2r"]["logfile"], maxBytes=(1048576 * 5), backupCount=3 

) 

lfh.setFormatter(lformat) 

logger.addHandler(lfh)