コード例 #1
0
ファイル: atc.py プロジェクト: mnezerka/sapcli
def profile_dump(connection, args):
    """Dumps ATC profiles."""

    result = sap.adt.atc.dump_profiles(connection, args.profiles,
                                       args.checkman)

    printout(json.dumps(result, indent=2))
コード例 #2
0
ファイル: wb.py プロジェクト: mnezerka/sapcli
    def begin(self, count):
        """Reports start of activation"""

        if count is None or count == 1:
            printout('Activating:')
        else:
            printout(f'Activating {count} objects:')
コード例 #3
0
ファイル: wb.py プロジェクト: mnezerka/sapcli
    def start_object(self, name, index, count):
        """Reports start of object activation"""

        end = '\n'
        if count is not None and count != 1:
            end = f' ({index}/{count})\n'

        printout('*', name, end=end)
コード例 #4
0
    def activate_objects(self, connection, args):
        """Actives the given object."""

        printout('Activating:')

        for name in args.name:
            printout('*', name)

            obj = self.instance(connection, name, args)
            sap.adt.wb.activate(obj)
コード例 #5
0
ファイル: object.py プロジェクト: siarhei-birych-sap/sapcli
def activate_object_list(activator, object_enumerable, count):
    """Starts object activation and handles results"""

    try:
        stats = activator.activate_sequentially(object_enumerable, count)
    except sap.cli.wb.StopObjectActivation as ex:
        printout('Activation has stopped')

        printout_activation_stats(ex.stats)

        if ex.stats.active_objects:
            printout('Active objects:')
            for obj in ex.stats.active_objects:
                printout_adt_object('  ', obj)

        return 1
    else:
        printout('Activation has finished')
        printout_activation_stats(stats)

        if stats.inactive_objects:
            printout('Inactive objects:')
            for obj in stats.inactive_objects:
                printout_adt_object('  ', obj)

            return 1

        return 1 if stats.errors > 0 else 0
コード例 #6
0
ファイル: object.py プロジェクト: mnezerka/sapcli
    def write_object_text(self, connection, args):
        """Changes source code of the given program include"""

        toactivate = collections.OrderedDict()

        printout('Writing:')

        for obj, text in write_args_to_objects(self, connection, args):
            printout('*', str(obj))

            with obj.open_editor(corrnr=args.corrnr) as editor:
                editor.write(''.join(text))

            toactivate[obj.name] = obj

        if not args.activate:
            return 0

        activated_items = toactivate.items()
        return activate_object_list(self.build_activator(args), activated_items, count=len(activated_items))
コード例 #7
0
ファイル: strust.py プロジェクト: mnezerka/sapcli
def listcertificates(connection, args):
    """Lists X.509 Base64 certificates currently installed in SAP system

        Exceptions:
            - SAPCliError:
                - when the given storage does not belong to the storage white list
                - when identity argument has invalid format
    """

    ssl_storages = ssl_storages_from_arguments(connection, args)

    for ssl_storage in ssl_storages:

        if not ssl_storage.exists():
            raise SAPCliError(
                f'Storage for identity {ssl_storage.identity} does not exist')

        for cert in ssl_storage.get_certificates():

            cert = ssl_storage.parse_certificate(cert)
            printout('*', cert['EV_SUBJECT'])
コード例 #8
0
    def write_object_text(self, connection, args):
        """Changes source code of the given program include"""

        toactivate = collections.OrderedDict()

        printout('Writing:')

        for obj, text in write_args_to_objects(self, connection, args):
            printout('*', str(obj))

            with obj.open_editor(corrnr=args.corrnr) as editor:
                editor.write(''.join(text))

            toactivate[obj.name] = obj

        if args.activate:
            printout('Activating:')

            for name, obj in toactivate.items():
                printout('*', name)

                sap.adt.wb.activate(obj)
コード例 #9
0
ファイル: datapreview.py プロジェクト: mnezerka/sapcli
def osql(connection, args):
    """Executes OpenSQL query"""

    sqlconsole = sap.adt.DataPreview(connection)
    table = sqlconsole.execute(args.statement, rows=args.rows, aging=args.noaging)

    if args.output == 'json':
        printout(json.dumps(table, indent=2))
    else:
        header = args.noheadings
        for row in table:
            if not header:
                printout(' | '.join(row.keys()))
                header = True

            printout(' | '.join(row.values()))
コード例 #10
0
ファイル: strust.py プロジェクト: mnezerka/sapcli
def dumpcertificates(connection, args):
    """Dumps X.509 Base64 certificates currently installed in SAP system

        Exceptions:
            - SAPCliError:
                - when the given storage does not belong to the storage white list
                - when identity argument has invalid format
    """

    ssl_storages = ssl_storages_from_arguments(connection, args)

    for ssl_storage in ssl_storages:

        if not ssl_storage.exists():
            raise SAPCliError(
                f'Storage for identity {ssl_storage.identity} does not exist')

        for cert in ssl_storage.get_certificates():

            c_b64 = base64.b64encode(cert)

            printout('-----BEGIN CERTIFICATE-----')
            printout(c_b64.decode('ascii'))
            printout('-----END CERTIFICATE-----')
コード例 #11
0
ファイル: atc.py プロジェクト: kozubikmichal/sapcli
def customizing(connection, _):
    """Retrieves ATC customizing"""

    settings = sap.adt.atc.fetch_customizing(connection)

    printout('System Check Variant:', settings.system_check_variant)
コード例 #12
0
 def print_entry(entry, prefix=''):
     printout(f'{prefix}{entry.object.name} ({entry.object.typ})')
コード例 #13
0
ファイル: atc.py プロジェクト: mnezerka/sapcli
def profile_list(connection, args):
    """Retrieves ATC profiles."""

    result = sap.adt.atc.fetch_profiles(connection)

    if args.output == 'json':
        printout(json.dumps(result, indent=2))
    else:
        header_printed = args.noheadings
        for (profile_id, profile) in result.items():

            # print header as the first line of the output
            if not header_printed:
                printout('profile_id', end='')
                if args.long:
                    printout(' | ' + ' | '.join(profile.keys()))
                else:
                    printout('')
                header_printed = True

            # print individual profiles
            printout(profile_id, end='')
            if args.long:
                printout(' | ' + ' | '.join(profile.values()))
            else:
                printout('')
コード例 #14
0
ファイル: wb.py プロジェクト: mnezerka/sapcli
    def handle_message(self, msg):
        """Reports an activation message"""

        printout(f'-- {msg.obj_descr}')
        printout(f'   {msg.typ}: {msg.short_text}')
コード例 #15
0
ファイル: object.py プロジェクト: siarhei-birych-sap/sapcli
def printout_adt_object(prefix, obj):
    """Prints out ADT object in identifiable way"""

    printout(f'{prefix}{obj.objtype.code} {obj.name}')
コード例 #16
0
ファイル: object.py プロジェクト: siarhei-birych-sap/sapcli
def printout_activation_stats(stats):
    """Prints out activation statistics"""

    printout('Warnings:', stats.warnings)
    printout('Errors:', stats.errors)