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

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

# Copyright 2015 The Distro Tracker Developers 

# See the COPYRIGHT file at the top-level directory of this distribution and 

# at https://deb.li/DTAuthors 

# 

# This file is part of Distro Tracker. It is subject to the license terms 

# in the LICENSE file found in the top-level directory of this 

# distribution and at https://deb.li/DTLicense. No part of Distro Tracker, 

# including this file, may be copied, modified, propagated, or distributed 

# except according to the terms contained in the LICENSE file. 

""" 

Kali specific rules 

""" 

 

import os.path 

import re 

 

from distro_tracker.core.package_tables import create_table 

from distro_tracker.debci_status.tracker_package_tables import DebciTableField 

from distro_tracker.mail import mail_news 

 

 

def classify_message(msg, package, keyword): 

"""Classify incoming email messages with a package and a keyword.""" 

# Default values for git commit notifications 

xgitrepo = msg.get('X-Git-Repo') 

26 ↛ 27line 26 didn't jump to line 27, because the condition on line 26 was never true if xgitrepo: 

if not package: 

if xgitrepo.endswith('.git'): 

xgitrepo = xgitrepo[:-4] 

package = os.path.basename(xgitrepo) 

if not keyword: 

keyword = 'vcs' 

 

# Recognize build logs 

35 ↛ 42line 35 didn't jump to line 42, because the condition on line 35 was never false if msg.get('X-Rebuildd-Host'): 

match = re.search(r'build of (\S+)_', msg.get('Subject')) 

37 ↛ 42line 37 didn't jump to line 42, because the condition on line 37 was never false if match: 

keyword = 'build' 

package = match.group(1) 

 

# Store some messages as news 

42 ↛ 43line 42 didn't jump to line 43, because the condition on line 42 was never true if msg.get('X-Distro-Tracker-News', 'no') == 'yes' and package: 

mail_news.create_news(msg, package) 

return (package, keyword) 

 

 

def approve_default_message(msg): 

""" 

The function should return a ``Boolean`` indicating whether this message 

should be forwarded to subscribers which are subscribed to default 

keyword messages. 

 

:param msg: The message to approve 

:type msg: :py:class:`email.message.Message` 

""" 

return False 

 

 

def get_table_fields(table): 

""" 

The function provides additional fields which should be displayed in 

the team's packages table 

""" 

return table.default_fields + [DebciTableField] 

 

 

def get_tables_for_team_page(team, limit): 

""" 

The function must return a list of :class:`BasePackageTable` objects 

to be displayed in the main page of teams. 

 

:param team: The team for which the tables must be added. 

:type package: :class:`Team <distro_tracker.core.models.Team>` 

:param int limit: The number of packages to be displayed in the tables 

""" 

return [ 

create_table(slug='general', scope=team, limit=limit), 

create_table( 

slug='general', scope=team, limit=limit, 

tag='tag:debci-failures') 

]