root/protocols/protocol_dummy.py

Revision 25, 4.9 kB (checked in by ploum, 3 years ago)

big bazar

Line 
1#!/usr/bin/python
2# -*- coding: utf-8 -*-
3import gtk
4import gobject
5from bug import bug
6# You have to change this if you have another storage
7from auth_dummy import user
8
9class protocol:
10
11# Available informations for authentification are :
12# -  user.login()  -> string that contains the login
13# -  user.password() -> string that contains the password
14
15################INFORMATION ABOUT THE BTS ################################
16
17        # Send back the name of the protocol as a simple string
18
19        def Name(self):
20                return "dummy"
21
22################BUG RETRIEVING IN THE BTS #################################
23       
24        # Functions related to bugs in your BTS
25        # Functions return an object "bug" (see bug.py)
26        #
27        # You have to implement the following functions :
28        # - retrieveBug(int)
29
30        def retrieveBug(self,nbr):
31                zebug = bug(nbr)
32                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33                # this is what you want to modify to support your own protocol
34                zebug.setTitle("Microsoft has a majority market share")
35                zebug.setDescription("Microsoft has a majority market share in the new desktop PC marketplace. This is a bug, which Ubuntu is designed to fix.\
36Microsoft has a majority market share | Non-free software is holding back innovation in the IT industry, restricting access to IT to a small part of the world's population and limiting the ability of software developers to reach their full potential, globally. This bug is widely evident in the PC industry.\
37Steps to repeat:\n  1. Visit a local PC store.\n What happens:\n   2. Observe that a majority of PC's for sale have non-free software pre-installed\n 3. Observe very few PC's with Ubuntu and free software pre-installed\n What should happen:\n  1. A majority of the PC's for sale should include only free software like Ubuntu\n  2. Ubuntu should be marketed in a way such that its amazing features and benefits would be apparent and known by all.\n  3. The system shall become more and more user friendly as time passes.")
38                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
39                return zebug   
40
41
42
43
44
45################SEARCH IN THE BTS #################################
46
47        # The functions Search will perform a search
48        # in the BTS
49        # All results matching the search are added to a
50        # gtk.ListStore with attributes in the following orders :
51        # gobject.TYPE_INT : number of the bug
52        # gobject.TYPE_STRING : package
53        # gobject.TYPE_STRING : title of the bug
54        # gobject.TYPE_STRING : importance
55        # gobject.TYPE_STRING : status
56        #
57        # You have to implement the following search methods for your BTS :
58        # - genericSearch(string)
59        # - packageSearch(string,string)
60        # - advancedSearch
61        # - packageExist(string) (return a boolean, not a listStore)
62
63
64        #private function to create a new result gtk.ListStore
65        def __newResult(self) :
66                return gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
67
68       
69        # genericSearch on a given string search_str.
70        def genericSearch(self, search_str) :
71                #creating an empty result first
72                results= self.__newResult()
73                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74                # this is what you want to modify to support your own protocol
75                #inserting dummies bugs
76                results.insert_before(None, [1, "Rhythmbox", search_str, "medium", "fixed"])
77                results.insert_before(None, [2, "gnome-panel", search_str, "low", "unconfirmed"])
78                results.insert_before(None, [3, "xterm", search_str, "urgent", "working"])
79                results.insert_before(None, [4, "ubuntu", search_str, "wontfix", "commited"])
80                results.insert_before(None, [5, "nautilus", search_str, "don't care", "confirmed"])
81                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82                #returning the results
83                return results
84
85        # search on a given string search_str but only in bugs of
86        # a given package
87        def packageSearch(self, package, search_str):
88                #creating an empty result first
89                results= self.__newResult()
90                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
91                # this is what you want to modify to support your own protocol
92                #inserting dummies bugs
93                if package == "evolution":
94                        results.insert_before(None, [1, "evolution", "search_str", "medium", "fixed"])
95                        results.insert_before(None, [2, "evolution", "search_str", "low", "unconfirmed"])
96                        results.insert_before(None, [3, "evolution", "search_str", "urgent", "working"])
97                        results.insert_before(None, [4, "evolution", "search_str", "wontfix", "commited"])
98                        results.insert_before(None, [5, "evolution", "search_str", "don't care", "confirmed"])
99                else :
100                        results.insert_before(None, [0, "No package of that name", "", "", ""])
101                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
102                #returning the results
103                return results
104
105       
106        # Return true is the package exist in the BTS, false if not             
107        def packageExist(self, package):
108                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
109                # this is what you want to modify to support your own protocol
110                return package == "evolution"
111                #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%         
112       
113
114                       
Note: See TracBrowser for help on using the browser.