Файловый менеджер - Редактировать - /usr/lib64/python3.6/site-packages/samba/netcmd/__pycache__/visualize.cpython-36.pyc
Ðазад
3 �I�d l � @ s: d dl Z d dlZd dlmZ d dlZd dlZd dljZd dl m Z d dl mZ d dlm Z mZmZmZ d dlmZ d dlmZ d dlmZmZ d d lmZ d d lmZ d dlmZmZmZ d dlZd dlZd dl m!Z!m"Z" d d l#m$Z$ d dl%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- eddde.ddd�eddde.ddd�edddddd�ed d!d"d#�ed$d%e/ej0� �d&�ed'd(d)d"d*d+�ed,d-d.d"d*d+�ed/d0d1d2d3d4�gZ1ed5d6dd7dd�ed8d9dd:dd�gZ2d;Z3G d<d=� d=e �Z4d>d?� Z5d@dA� Z6dBdC� Z7G dDdE� dEe4�Z8G dFdG� dGe9�Z:G dHdI� dIe4�Z;G dJdK� dKe4�Z<G dLdM� dMe�Z=dS )N� N)�defaultdict)�dsdb)�nttime2unix)�Command�SuperCommand�CommandError�Option)�SamDB)� dot_graph)�distance_matrix�COLOUR_SETS)�full_matrix)�is_colour_wanted)� SCOPE_BASE� SCOPE_SUBTREE�LdbError)�KCC�ldif_import_export)�KCCError)�get_partition_maps� get_partition�get_own_cursor�get_utdv�get_utdv_edges�get_utdv_distances�get_utdv_max_distance�get_kcc_and_dsasz-Hz--URLz%LDB URL for database or target serverZURL�H)�help�type�metavar�destz-oz--outputzwrite here (default stdout)�FILE)r r r �defaultz --distancez&Distance matrix graph output (default)�format�distance�store_const)r r! �const�actionz--utf8zUse utf-8 Unicode characters� store_true)r r( z--color-schemez,use this colour scheme (implies --color=yes))r �choicesz-Sz--shorten-namesz don't print long common suffixesF)r r( r# z-rz--talk-to-remotezquery other DCs' databasesz--no-keyzomit the explanatory keyZstore_falseT�key)r r( r# r! z--dotzGraphviz dot output�dotz--xdotzattempt to call Graphviz xdot�xdotZ__temp__c @ s\ e Zd ZdZdZejejejd�Z e e Zf Z dd� Zddd �Zd d� Zdd � Zdd� ZdS )�GraphCommandz Base class for graphing commandsz%prog [options])� sambaopts�versionopts�credoptsc C s( |j � }|j|dd�}t|||d�}|S )NT)�fallback_machine)ZurlZcredentials�lp)�get_loadparm�get_credentialsr )�selfr r/ r1 r3 �creds�samdb� r9 �!/usr/lib64/python3.6/visualize.py�get_db^ s zGraphCommand.get_dbN�.dotc C sr |dks|dkr"t || jd� dS |tkrRtjd|d�\}}t|d�}tj|� n t|d�}|j|� |j� |S )a� Decide whether we're dealing with a filename, a tempfile, or stdout, and write accordingly. :param s: the string to write :param fn: a destination :param suffix: suffix, if destination is a tempfile If fn is None or "-", write to stdout. If fn is visualize.TEMP_FILE, write to a temporary file Otherwise fn should be a filename to write to. N�-)�filezsamba-tool-visualise)�prefix�suffix�w) �print�outf� TEMP_FILE�tempfileZmkstemp�open�os�close�write)r6 �s�fnr@ �fd�fr9 r9 r: rI d s zGraphCommand.writec C s. |s|r|j � jd�rdS dS |dkr*dS |S )z5Heuristics to work out what output format was wanted.z.dotr, r% r- )�lower�endswith)r6 r$ �outputr9 r9 r: �calc_output_format� s zGraphCommand.calc_output_formatc C sL |d kr| j |t�}n| j ||�}tjjdd�}tj||g� tj|� d S )NZSAMBA_TOOL_XDOT_PATHz /usr/bin/xdot)rI rD rG �environ�get� subprocessZcall�remove)r6 rJ rP rK r- r9 r9 r: � call_xdot� s zGraphCommand.call_xdotc C sJ |dk r|S |d kr| j }t|| jd�}|s0dS dtjjdd�krFdS dS ) z�Heuristics to work out the colour scheme for distance matrices. Returning None means no colour, otherwise it should be a colour from graph.COLOUR_SETSNr= )ZhintZ256colorZTERM� zxterm-256color-heatmap�ansi)r= N)rC r Zrequested_colourrG rR rS )r6 �color_schemerP Zwant_colourr9 r9 r: �calc_distance_color_scheme� s z'GraphCommand.calc_distance_color_scheme)Nr<