Passed
Push — master ( 2adcb6...75d235 )
by Markus
01:50
created

EncryptHeaderRequest.get_headers()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 1
1
# -*- coding: utf-8 -*-
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
2
3
from collections import OrderedDict
4
from .. import credentials, devices
0 ignored issues
show
Unused Code introduced by
The import devices seems to be unused.
Loading history...
5
from .tclrequest import TclRequest
6
from .tclresult import EncryptHeaderResult
7
8
class EncryptHeaderRequest(TclRequest):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
9
    def __init__(self, file_uri):
10
        super().__init__()
11
        # NOTE: THIS HAS TO BE RUN ON AN ENCSLAVE
12
        self.uri = "/encrypt_header.php"
13
        self.rawmode = True
14
        self.method = "POST"
15
        self.file_uri = file_uri
16
17
    def get_headers(self):
18
        return {"User-Agent": "tcl"}
19
20
    def get_params(self):
21
        params = OrderedDict()
22
        params.update(credentials.get_creds2())
23
        params["address"] = bytes(self.file_uri, "utf-8")
24
        return params
25
26
    def is_done(self, http_status: int, contents: str) -> bool:
27
        # Expect "HTTP 206 Partial Content" response
28
        if http_status == 206:
29
            self.result = EncryptHeaderResult(contents)
30
            self.success = True
31
            return True
32
        self.error = "HTTP {}".format(http_status)
33
        self.success = False
34
        return True
35