Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bsock.py « bsock « bareos - github.com/bareos/python-bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 746c270bf7bca5323329ed83b1f155575fabae9c (plain)
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
"""
Communicates with the bareos-director
"""

from    bareos.bsock.lowlevel import LowLevel
import  sys

class BSock(LowLevel):
    '''use to send and receive the response from director'''

    def __init__(self,
                 address="localhost",
                 port=9101,
                 dirname=None,
                 name="*UserAgent*",
                 password=None):
        super(BSock, self).__init__()
        self.connect(address, port, dirname)
        self.auth(name=name, password=password)
        self._set_state_director_prompt()


    def call(self, command):
        '''
        call a bareos-director user agent command
        '''
        self.send(str(command))
        return self.recv_msg()


    def send_command(self, commamd):
        return self.call(command)


    def interactive(self):
        """
        Enter the interactive mode.
        Exit via typing "exit" or "quit".
        """
        self._set_state_director_prompt()
        command = ""
        while command != "exit" and command != "quit":
            command = raw_input(">>")
            resultmsg = self.call(command)
            sys.stdout.write(resultmsg)
        return True