Ejemplo n.º 1
0
 def __init__(self,
              teamscale_config,
              repository_path,
              analyzed_file=None,
              verify=True):
     """Constructor"""
     self.repository_path = repository_path
     self.teamscale_client = TeamscaleClient(teamscale_config.url,
                                             teamscale_config.username,
                                             teamscale_config.access_token,
                                             teamscale_config.project_id,
                                             verify)
     self.analyzed_file = analyzed_file
Ejemplo n.º 2
0
 def __init__(self, teamscale_config, repository_path, analyzed_file=None, verify=True):
     """Constructor"""
     self.repository_path = repository_path
     self.teamscale_client = TeamscaleClient(teamscale_config.url, teamscale_config.username,
                                             teamscale_config.access_token, teamscale_config.project_id,
                                             verify)
     self.analyzed_file = analyzed_file
def get_client(branch=None):
    """Returns Teamscale client object for requesting servers"""
    responses.add(responses.GET,
                  get_global_service_mock('service-api-info'),
                  status=200,
                  content_type="application/json",
                  body='{ "apiVersion": 6}')
    return TeamscaleClient(URL, "admin", "admin", "foo", branch=branch)
def main(coverage_folder):
    print("\n---> checking for new coverage at %s" % datetime.datetime.now())
    projects = [
        f for f in os.listdir(coverage_folder)
        if os.path.isdir(os.path.join(coverage_folder, f))
    ]
    for project in projects:
        project_path = os.path.join(coverage_folder, project)
        client = TeamscaleClient(TEAMSCALE_URL, USERNAME, ACCESS_TOKEN,
                                 project)
        coverage_files = [
            f for f in os.listdir(project_path)
            if os.path.isfile(os.path.join(project_path, f))
        ]
        for coverage_file in coverage_files:
            coverage_path = os.path.join(project_path, coverage_file)
            format = os.path.splitext(coverage_file)[1]
            print("uploading coverage to %s from %s" %
                  (project, coverage_file))
            client.upload_coverage_data([coverage_path], format,
                                        datetime.datetime.now(),
                                        "Unit Test Coverage Upload",
                                        "Unit Test Coverage")
            os.remove(coverage_path)
def test_add_project_without_validation():
    """Test adding projects"""
    file_system_config = FileSystemSourceCodeConnectorConfiguration(
        input_directory="/path/to/folder",
        repository_identifier="Local",
        included_file_names="**.py")
    project_configuration = ProjectConfiguration(
        name="Test Project",
        project_id="test-project",
        profile="Python (default)",
        connectors=[file_system_config])

    responses.add(responses.PUT,
                  get_global_service_mock('create-project'),
                  body='{"message": "success"}',
                  status=200)
    resp = get_client().create_project(project_configuration, True)
    assert resp.status_code == 200 and TeamscaleClient._get_response_message(
        resp) == SUCCESS
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import datetime

from teamscale_client import TeamscaleClient
from teamscale_client.constants import AssessmentMetricColors
from teamscale_client.data import NonCodeMetricEntry


TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "test"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)

    entry = NonCodeMetricEntry("/non/code/metric/path", "This is a test content", {AssessmentMetricColors.RED: 2, AssessmentMetricColors.GREEN : 1}, 25.0)
    entry2 = NonCodeMetricEntry("/non/code/metric/path2", "This is a test content 2", {AssessmentMetricColors.RED: 1, AssessmentMetricColors.GREEN : 4}, 40.)

    client.upload_non_code_metrics([entry, entry2], datetime.datetime.now() , "Upload non-code metrics", "test-partition")
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from teamscale_client import TeamscaleClient
from teamscale_client.data import MetricDescription

TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "foo"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)

    description = MetricDescription("sample_metric_id", "Sample Metric", "A great sample description", "Sample Metrics")
    client.add_metric_descriptions([description])
from teamscale_client.data import Baseline


TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
ACCESS_TOKEN = "ide-access-token"

PROJECT_ID = "test"

def show_baselines(client):
    baselines = client.get_baselines()
    print([str(baseline) for baseline in baselines])

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, ACCESS_TOKEN, PROJECT_ID)

    baseline = Baseline("Test Baseline", "This is a test description", datetime.datetime.now())

    client.add_baseline(baseline)

    show_baselines(client)

    baseline = Baseline("Test Baseline", "This is a test description", datetime.datetime.now())
    client.add_baseline(baseline)

    baseline2 = Baseline("Test Baseline 2", "This is a test description", datetime.datetime.now())
    client.add_baseline(baseline2)

    show_baselines(client)
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import glob
import datetime

from teamscale_client import TeamscaleClient
from teamscale_client.constants import CoverageFormats

TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "test"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)

    client.upload_architectures({"architectures/system.architecture": "/path/to/system.architecture"}, datetime.datetime.now(), "Upload architecture")
    metricValuesDict['F-RT-D'] = 1000 * metricValuesDict['F-RT'] / sloc
    metricValuesDict['F-UC-D'] = 1000 * metricValuesDict['F-UC'] / sloc
    metricValuesDict['F-MC-D'] = 1000 * metricValuesDict['F-MC'] / sloc
    metricValuesDict['F-UVP-D'] = 1000 * metricValuesDict['F-UVP'] / sloc

def get_ordered_metric_values(metricValuesDict):
    valuesList = []
    for element in outputFileHeader:
        if (element == "id"):
            continue
        valuesList.append(metricValuesDict[element])
    return valuesList

if __name__ == '__main__':
    print("Program Started, build REST Client...")
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, ACCESS_TOKEN, PROJECT_ID)
    firstVersionTimestamp = 1519862400000
    versionsInterval = 86400000
    metricValuesAllVersions = dict()
    metricValuesAllVersions[0] = outputFileHeader
    for versionCntr in range(0,VERSIONS):      # range end is excluding
        if (versionCntr+1 >= VERSION_NEW_PATH_FROM):
            RELATIVE_PATH = NEW_RELATIVE_PATH
        if (versionCntr+1 > VERSION_NEW_PATH_TILL):
            RELATIVE_PATH = OLD_RELATIVE_PATH
        versionTimestamp = firstVersionTimestamp + versionCntr * versionsInterval + 10000000
        print("DEBUG: Processing version ", versionCntr+1, "    timestamp of REST request: ", versionTimestamp)
        parameters = {"t":"default:" + str(versionTimestamp), "configurationName":"Teamscale Default"}
        r = client.get(TEAMSCALE_URL + "/p/" + PROJECT_ID.lower() + "/metric-table/", parameters)
        metricValues = extract_values_from_JSON_resp(r.json())
        if(check_metricValues_contains_all_metrics(metricValues)):
Ejemplo n.º 11
0
    outputFile = open(filePath, "w", newline='')
    print("DEBUG: Writing values to output file: ", filePath)
    write_metric_values_to_output_file(outputFile, metricValuesVersions)
    outputFile.close()
    CSV_SEPERATOR_CHAR = ';'
    OUTPUT_FILE_NAME = "buggyFiles_staticMetrics_excel_format.csv"
    filePath = OUTPUT_DIR + "\\" + PROJECT_ID + "\\" + OUTPUT_FILE_NAME
    outputFileExcel = open(filePath, "w", newline='')
    print("DEBUG: Writing values to output file: ", filePath)
    write_metric_values_to_output_file(outputFileExcel, metricValuesVersions)
    outputFileExcel.close()


if __name__ == '__main__':
    print("Program Started, build REST Client...")
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, ACCESS_TOKEN, PROJECT_ID)
    firstVersionTimestamp = 1519862400000
    versionsInterval = 86400000
    metricValuesVersions = dict()
    metricValuesVersions[0] = outputFileHeader
    for versionCntr in range(0, VERSIONS):  # range end is excluding
        versionTimestamp = firstVersionTimestamp + versionCntr * versionsInterval + 10000000
        print("DEBUG: Processing version ", str(versionCntr + 1),
              " unix timestamp: ", versionTimestamp)
        if (versionCntr + 1 > VERSION_NEW_PREFIX):
            MC_PATH_PREFIX = MC_PATH_NEW_PREFIX
        buggyFiles = get_buggy_files(versionCntr + 1)
        fileCntr = 1
        metricValuesVersionFiles = dict()
        for file in buggyFiles:
            jsonResp = get_request(client, versionTimestamp, file)
def get_client():
    return TeamscaleClient(URL, "admin", "admin", "foo")
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import glob
import datetime

from teamscale_client import TeamscaleClient
from teamscale_client.constants import CoverageFormats

TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "test"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)

    files = [ file for file in glob.glob("/path/to/coverage/files/*.xml")]

    client.upload_coverage_data(files, CoverageFormats.CTC , datetime.datetime.now(), "Upload coverage", "test-partition")
Ejemplo n.º 14
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from teamscale_client import TeamscaleClient
from teamscale_client.data import MetricDescription

TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
ACCESS_TOKEN = "ide-access-token"

PROJECT_ID = "foo"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, ACCESS_TOKEN, PROJECT_ID)

    description = MetricDescription("sample_metric_id", "Sample Metric", "A great sample description", "Sample Metrics")
    client.add_metric_descriptions([description])
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import glob
import datetime

from teamscale_client import TeamscaleClient
from teamscale_client.constants import ReportFormats

TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
ACCESS_TOKEN = "ide-access-token"

PROJECT_ID = "test"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, ACCESS_TOKEN, PROJECT_ID)

    files = [file for file in glob.glob("/path/to/report.xml")]

    client.upload_report(files, ReportFormats.PCLINT, datetime.datetime.now(),
                         "Upload PCLint results", "test-partition")
Ejemplo n.º 16
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import glob
import datetime

from teamscale_client import TeamscaleClient
from teamscale_client.constants import CoverageFormats

TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "test"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)

    client.upload_architectures(
        {"architectures/system.architecture": "/path/to/system.architecture"},
        datetime.datetime.now(), "Upload architecture")
import sys

from teamscale_client import TeamscaleClient
from teamscale_client.constants import Enablement
from teamscale_client.data import Finding, FileFindings, FindingDescription


TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "test"

if __name__ == "__main__":
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)

    # Add a new group that will contain findings
    response = client.add_findings_group("Group 1", "externals-.*")
    print("Request result: %s" % (response.text,))

    # Make Teamscale aware of a new findings type, which mappes to the previously
    # created group
    descriptions = [FindingDescription("externals-1", "A test finding description", Enablement.RED)]
    response = client.add_finding_descriptions(descriptions)
    print("Request result: %s" % (response.text,))

    # A manual step to add the new groups to existing analysis profiles has to be done.
    if sys.version_info[0] == 2:
        raw_input(
            "Please create the project or update the analysis profile used by the project to contain the new groups. Then Press ENTER to continue."
Ejemplo n.º 18
0
class PrecommitClient:
    """Client for precommit analysis"""

    def __init__(self, teamscale_config, repository_path, analyzed_file=None, verify=True):
        """Constructor"""
        self.repository_path = repository_path
        self.teamscale_client = TeamscaleClient(teamscale_config.url, teamscale_config.username,
                                                teamscale_config.access_token, teamscale_config.project_id,
                                                verify)
        self.analyzed_file = analyzed_file

    def upload_precommit_data(self, changed_files, deleted_files):
        """Uploads the currently changed files for precommit analysis."""
        current_branch = get_current_branch(self.repository_path)
        self.teamscale_client.branch = current_branch
        parent_commit_timestamp = get_current_timestamp(self.repository_path)

        print("Uploading changes on branch '%s' in '%s'..." % (current_branch, self.repository_path))
        precommit_data = PreCommitUploadData(uniformPathToContentMap=changed_files, deletedUniformPaths=deleted_files)
        self.teamscale_client.upload_files_for_precommit_analysis(
            datetime.datetime.fromtimestamp(int(parent_commit_timestamp)), precommit_data)

    def wait_and_get_precommit_result(self):
        """Gets the current precommit results. Waits synchronously until server is ready. """
        return self.teamscale_client.get_precommit_analysis_results()

    def print_precommit_results_as_error_string(self, include_findings_in_changed_code=True):
        """Print the current precommit results formatting them in a way, most text editors understand.

        Returns:
            `True`, if RED findings were among the new findings. `False`, otherwise.
        """
        added_findings, removed_findings, findings_in_changed_code = self.wait_and_get_precommit_result()

        print('New findings:')
        for formatted_finding in self._format_findings(added_findings):
            print(formatted_finding)

        if include_findings_in_changed_code:
            print('')
            print('Findings in changed code:')
            for formatted_finding in self._format_findings(findings_in_changed_code):
                print(formatted_finding)

        red_added_findings = list(filter(lambda finding: finding.assessment == "RED", added_findings))
        return len(red_added_findings) > 0

    def print_other_findings_as_error_string(self, include_all_findings=True):
        """Print existing findings for the current file or the whole repo in a way, most text editors understand. """
        uniform_path = os.path.relpath(self.analyzed_file, self.repository_path)
        if include_all_findings:
            uniform_path = ''

        existing_findings = self.teamscale_client.get_findings(
            uniform_path=uniform_path,
            timestamp=datetime.datetime.fromtimestamp(int(get_current_timestamp(self.repository_path))))

        print('')
        print('Existing findings:')
        for formatted_finding in self._format_findings(existing_findings):
            print(formatted_finding)

    def _format_findings(self, findings):
        """Formats the given findings as error or warning strings."""
        if len(findings) == 0:
            return ['> No findings.']
        sorted_findings = sorted(findings)
        return [os.path.join(self.repository_path, finding.uniformPath) + ':' + str(finding.startLine) + ':0: ' +
                self._severity_string(finding=finding) + ': ' + finding.message for finding in sorted_findings]

    def _severity_string(self, finding):
        """Formats the given finding's assessment as severity."""
        return 'error' if finding.assessment == 'RED' else 'warning'
import datetime
import sys

from teamscale_client import TeamscaleClient
from teamscale_client.constants import Enablement
from teamscale_client.data import Finding, FileFindings, FindingDescription

TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
ACCESS_TOKEN = "ide-access-token"

PROJECT_ID = "test"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, ACCESS_TOKEN, PROJECT_ID)

    # Add a new group that will contain findings
    response = client.add_findings_group("Group 1", "externals-.*")
    print("Request result: %s" % (response.text, ))

    # Make Teamscale aware of a new findings type, which mappes to the previously
    # created group
    descriptions = [
        FindingDescription("externals-1", "A test finding description",
                           Enablement.RED),
        FindingDescription("externals-2", "Another finding description",
                           Enablement.YELLOW, "externals-2")
    ]
    response = client.add_finding_descriptions(descriptions)
    print("Request result: %s" % (response.text, ))
Ejemplo n.º 20
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import datetime

from teamscale_client import TeamscaleClient
from teamscale_client.data import MetricEntry

TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "foo"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)

    entry = MetricEntry("src/Foo.java", {"sample_metric_id": 10})
    entry2 = MetricEntry("-architectures-/system.architecture/src/empty/",
                         {"sample_metric_id": 6})

    client.upload_metrics([entry2], datetime.datetime.now(), "Upload metrics",
                          "test-partition")
Ejemplo n.º 21
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import glob
import datetime

from teamscale_client import TeamscaleClient
from teamscale_client.constants import CoverageFormats

TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
ACCESS_TOKEN = "ide-access-token"

PROJECT_ID = "test"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, ACCESS_TOKEN, PROJECT_ID)

    client.upload_architectures(
        {"architectures/system.architecture": "/path/to/system.architecture"},
        datetime.datetime.now(), "Upload architecture")
Ejemplo n.º 22
0
from teamscale_client import TeamscaleClient

TEAMSCALE_URL="http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "foo"

if __name__ == '__main__':
    findings = [
        {
            "findings" : [
                {
                    "findingTypeId": "externals-2-type-2",
                        "message": "test",
                        "assessment": "RED",
                        "startLine": 1,
                        "endLine": 1,
                        "startOffset": 1,
                        "endOffset": 26
                }
            ],
            "path": "src/main/java/junit/extensions/ActiveTestSuite.java"
        }
    ]
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)
    response = client.upload_findings(findings, 1459554747999, "TestCommit", "test-partition")
    print "Request result: %s" % (response.text, )
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import glob
import datetime

from teamscale_client import TeamscaleClient
from teamscale_client.constants import CoverageFormats

TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "test"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)

    files = [file for file in glob.glob("/path/to/coverage/files/*.xml")]

    client.upload_coverage_data(files, CoverageFormats.CTC,
                                datetime.datetime.now(), "Upload coverage",
                                "test-partition")
Ejemplo n.º 24
0
class PrecommitClient:
    """Client for precommit analysis"""
    def __init__(self,
                 teamscale_config,
                 repository_path,
                 analyzed_file=None,
                 verify=True):
        """Constructor"""
        self.repository_path = repository_path
        self.teamscale_client = TeamscaleClient(teamscale_config.url,
                                                teamscale_config.username,
                                                teamscale_config.access_token,
                                                teamscale_config.project_id,
                                                verify)
        self.analyzed_file = analyzed_file

    def upload_precommit_data(self, changed_files, deleted_files):
        """Uploads the currently changed files for precommit analysis."""
        current_branch = get_current_branch(self.repository_path)
        self.teamscale_client.branch = current_branch
        parent_commit_timestamp = get_current_timestamp(self.repository_path)

        print("Uploading changes on branch '%s' in '%s'..." %
              (current_branch, self.repository_path))
        precommit_data = PreCommitUploadData(
            uniformPathToContentMap=changed_files,
            deletedUniformPaths=deleted_files)
        self.teamscale_client.upload_files_for_precommit_analysis(
            datetime.datetime.fromtimestamp(int(parent_commit_timestamp)),
            precommit_data)

    def wait_and_get_precommit_result(self):
        """Gets the current precommit results. Waits synchronously until server is ready. """
        return self.teamscale_client.get_precommit_analysis_results()

    def print_precommit_results_as_error_string(
            self, include_findings_in_changed_code=True):
        """Print the current precommit results formatting them in a way, most text editors understand.

        Returns:
            `True`, if RED findings were among the new findings. `False`, otherwise.
        """
        added_findings, removed_findings, findings_in_changed_code = self.wait_and_get_precommit_result(
        )

        print('New findings:')
        for formatted_finding in self._format_findings(added_findings):
            print(formatted_finding)

        if include_findings_in_changed_code:
            print('')
            print('Findings in changed code:')
            for formatted_finding in self._format_findings(
                    findings_in_changed_code):
                print(formatted_finding)

        red_added_findings = list(
            filter(lambda finding: finding.assessment == "RED",
                   added_findings))
        return len(red_added_findings) > 0

    def print_other_findings_as_error_string(self, include_all_findings=True):
        """Print existing findings for the current file or the whole repo in a way, most text editors understand. """
        uniform_path = os.path.relpath(self.analyzed_file,
                                       self.repository_path)
        if include_all_findings:
            uniform_path = ''

        existing_findings = self.teamscale_client.get_findings(
            uniform_path=uniform_path,
            timestamp=datetime.datetime.fromtimestamp(
                int(get_current_timestamp(self.repository_path))))

        print('')
        print('Existing findings:')
        for formatted_finding in self._format_findings(existing_findings):
            print(formatted_finding)

    def _format_findings(self, findings):
        """Formats the given findings as error or warning strings."""
        if len(findings) == 0:
            return ['> No findings.']
        sorted_findings = sorted(findings)
        return [
            os.path.join(self.repository_path, finding.uniformPath) + ':' +
            str(finding.startLine) + ':0: ' +
            self._severity_string(finding=finding) + ': ' + finding.message
            for finding in sorted_findings
        ]

    def _severity_string(self, finding):
        """Formats the given finding's assessment as severity."""
        return 'error' if finding.assessment == 'RED' else 'warning'
Ejemplo n.º 25
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import datetime

from teamscale_client import TeamscaleClient
from teamscale_client.constants import AssessmentMetricColors
from teamscale_client.data import NonCodeMetricEntry


TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
ACCESS_TOKEN = "ide-access-token"

PROJECT_ID = "test"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, ACCESS_TOKEN, PROJECT_ID)

    entry = NonCodeMetricEntry("/non/code/metric/path", "This is a test content", 3, {AssessmentMetricColors.RED: 2, AssessmentMetricColors.GREEN : 1}, 25.0)
    entry2 = NonCodeMetricEntry("/non/code/metric/path2", "This is a test content 2", 5, {AssessmentMetricColors.RED: 1, AssessmentMetricColors.GREEN : 4}, 40.)

    client.upload_non_code_metrics([entry, entry2], datetime.datetime.now() , "Upload non-code metrics", "test-partition")
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import datetime

from teamscale_client import TeamscaleClient
from teamscale_client.data import MetricEntry


TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "foo"

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)

    entry = MetricEntry("src/Foo.java", {"sample_metric_id" : 10})
    entry2 = MetricEntry("-architectures-/system.architecture/src/empty/", {"sample_metric_id" : 6})

    client.upload_metrics([entry2], datetime.datetime.now() , "Upload metrics", "test-partition")
Ejemplo n.º 27
0
from teamscale_client.data import Baseline


TEAMSCALE_URL = "http://localhost:8080"

USERNAME = "******"
PASSWORD = "******"

PROJECT_NAME = "test"

def show_baselines(client):
    baselines = client.get_baselines()
    print([str(baseline) for baseline in baselines])

if __name__ == '__main__':
    client = TeamscaleClient(TEAMSCALE_URL, USERNAME, PASSWORD, PROJECT_NAME)

    baseline = Baseline("Test Baseline", "This is a test description", datetime.datetime.now())

    client.add_baseline(baseline)

    show_baselines(client)

    baseline = Baseline("Test Baseline", "This is a test description", datetime.datetime.now())
    client.add_baseline(baseline)

    baseline2 = Baseline("Test Baseline 2", "This is a test description", datetime.datetime.now())
    client.add_baseline(baseline2)

    show_baselines(client)