21

Re: Python - запитання

Tarasiy написав:

Error 503 Backend is unhealthy

Пробува встановити, пише що не може знайти.

PyPi іноді не добре себе почуває. Спробуйте ще раз, або дзеркало.

22

Re: Python - запитання

~>sudo  pip install pynetinfo
Downloading/unpacking pynetinfo
  Downloading Pynetinfo-0.2.3.tar.gz
  Storing download in cache at ./.cache/pip/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpynetinfo%2FPynetinfo-0.2.3.tar.gz
  Running setup.py egg_info for package pynetinfo
   
Installing collected packages: pynetinfo
  Running setup.py install for pynetinfo
    building 'netinfo' extension
    i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c netinfo.c -o build/temp.linux-i686-2.7/netinfo.o
    i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c iface.c -o build/temp.linux-i686-2.7/iface.o
    i686-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c route.c -o build/temp.linux-i686-2.7/route.o
    i686-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security build/temp.linux-i686-2.7/netinfo.o build/temp.linux-i686-2.7/iface.o build/temp.linux-i686-2.7/route.o -o build/lib.linux-i686-2.7/netinfo.so
    changing mode of build/scripts-2.7/test.py from 644 to 755
   
    changing mode of /usr/local/bin/test.py to 755
Successfully installed pynetinfo
Cleaning up...

23

Re: Python - запитання

який механізм передачі даних з javascript  ---> python ?
наприклад - я хочу передати контролеру на сервері файл, який на локальному комп’ютері.
засобами js я його вибираю, далі ?
теоретично мав би створити об’єкт, який передам методом post?

24 Востаннє редагувалося Singularity (27.12.2013 13:43:14)

Re: Python - запитання

Нема ніяких механізмів. Пишешь в’юху з формою яка приймає та зберігає файл, а потім js`ом робиш запит до цієї в’юхи.

25 Востаннє редагувалося ping (27.12.2013 15:10:31)

Re: Python - запитання

Singularity написав:

Нема ніяких механізмів. Пишешь в’юху з формою яка приймає та зберігає файл, а потім js`ом робиш запит до цієї в’юхи.

може я не точно описав питання.
є потреба редагувати вміст сторінки за допомогою wysiwyg редактора CKEditor:

Прихований текст
/**
 * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 */

/**
 * @fileOverview The "filebrowser" plugin that adds support for file uploads and
 *               browsing.
 *
 * When a file is uploaded or selected inside the file browser, its URL is
 * inserted automatically into a field defined in the <code>filebrowser</code>
 * attribute. In order to specify a field that should be updated, pass the tab ID and
 * the element ID, separated with a colon.<br /><br />
 *
 * <strong>Example 1: (Browse)</strong>
 *
 * <pre>
 * {
 *     type : 'button',
 *     id : 'browse',
 *     filebrowser : 'tabId:elementId',
 *     label : editor.lang.common.browseServer
 * }
 * </pre>
 *
 * If you set the <code>filebrowser</code> attribute for an element other than
 * the <code>fileButton</code>, the <code>Browse</code> action will be triggered.<br /><br />
 *
 * <strong>Example 2: (Quick Upload)</strong>
 *
 * <pre>
 * {
 *     type : 'fileButton',
 *     id : 'uploadButton',
 *     filebrowser : 'tabId:elementId',
 *     label : editor.lang.common.uploadSubmit,
 *     'for' : [ 'upload', 'upload' ]
 * }
 * </pre>
 *
 * If you set the <code>filebrowser</code> attribute for a <code>fileButton</code>
 * element, the <code>QuickUpload</code> action will be executed.<br /><br />
 *
 * The filebrowser plugin also supports more advanced configuration performed through
 * a JavaScript object.
 *
 * The following settings are supported:
 *
 * <ul>
 * <li><code>action</code> &ndash; <code>Browse</code> or <code>QuickUpload</code>.</li>
 * <li><code>target</code> &ndash; the field to update in the <code><em>tabId:elementId</em></code> format.</li>
 * <li><code>params</code> &ndash; additional arguments to be passed to the server connector (optional).</li>
 * <li><code>onSelect</code> &ndash; a function to execute when the file is selected/uploaded (optional).</li>
 * <li><code>url</code> &ndash; the URL to be called (optional).</li>
 * </ul>
 *
 * <strong>Example 3: (Quick Upload)</strong>
 *
 * <pre>
 * {
 *     type : 'fileButton',
 *     label : editor.lang.common.uploadSubmit,
 *     id : 'buttonId',
 *     filebrowser :
 *     {
 *         action : 'QuickUpload', // required
 *         target : 'tab1:elementId', // required
 *         params : // optional
 *         {
 *             type : 'Files',
 *             currentFolder : '/folder/'
 *         },
 *         onSelect : function( fileUrl, errorMessage ) // optional
 *         {
 *             // Do not call the built-in selectFuntion.
 *             // return false;
 *         }
 *     },
 *     'for' : [ 'tab1', 'myFile' ]
 * }
 * </pre>
 *
 * Suppose you have a file element with an ID of <code>myFile</code>, a text
 * field with an ID of <code>elementId</code> and a <code>fileButton</code>.
 * If the <code>filebowser.url</code> attribute is not specified explicitly,
 * the form action will be set to <code>filebrowser[<em>DialogWindowName</em>]UploadUrl</code>
 * or, if not specified, to <code>filebrowserUploadUrl</code>. Additional parameters
 * from the <code>params</code> object will be added to the query string. It is
 * possible to create your own <code>uploadHandler</code> and cancel the built-in
 * <code>updateTargetElement</code> command.<br /><br />
 *
 * <strong>Example 4: (Browse)</strong>
 *
 * <pre>
 * {
 *     type : 'button',
 *     id : 'buttonId',
 *     label : editor.lang.common.browseServer,
 *     filebrowser :
 *     {
 *         action : 'Browse',
 *         url : '/ckfinder/ckfinder.html&amp;type=Images',
 *         target : 'tab1:elementId'
 *     }
 * }
 * </pre>
 *
 * In this example, when the button is pressed, the file browser will be opened in a
 * popup window. If you do not specify the <code>filebrowser.url</code> attribute,
 * <code>filebrowser[<em>DialogName</em>]BrowseUrl</code> or
 * <code>filebrowserBrowseUrl</code> will be used. After selecting a file in the file
 * browser, an element with an ID of <code>elementId</code> will be updated. Just
 * like in the third example, a custom <code>onSelect</code> function may be defined.
 */

(function() {
    // Adds (additional) arguments to given url.
    //
    // @param {String}
    //            url The url.
    // @param {Object}
    //            params Additional parameters.
    function addQueryString( url, params ) {
        var queryString = [];

        if ( !params )
            return url;
        else {
            for ( var i in params )
                queryString.push( i + "=" + encodeURIComponent( params[ i ] ) );
        }

        return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );
    }

    // Make a string's first character uppercase.
    //
    // @param {String}
    //            str String.
    function ucFirst( str ) {
        str += '';
        var f = str.charAt( 0 ).toUpperCase();
        return f + str.substr( 1 );
    }

    // The onlick function assigned to the 'Browse Server' button. Opens the
    // file browser and updates target field when file is selected.
    //
    // @param {CKEDITOR.event}
    //            evt The event object.
    function browseServer( evt ) {
        var dialog = this.getDialog();
        var editor = dialog.getParentEditor();

        editor._.filebrowserSe = this;

        var width = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowWidth' ] || editor.config.filebrowserWindowWidth || '80%';
        var height = editor.config[ 'filebrowser' + ucFirst( dialog.getName() ) + 'WindowHeight' ] || editor.config.filebrowserWindowHeight || '70%';

        var params = this.filebrowser.params || {};
        params.CKEditor = editor.name;
        params.CKEditorFuncNum = editor._.filebrowserFn;
        if ( !params.langCode )
            params.langCode = editor.langCode;

        var url = addQueryString( this.filebrowser.url, params );
        // TODO: V4: Remove backward compatibility (#8163).
        editor.popup( url, width, height, editor.config.filebrowserWindowFeatures || editor.config.fileBrowserWindowFeatures );
    }

    // The onlick function assigned to the 'Upload' button. Makes the final
    // decision whether form is really submitted and updates target field when
    // file is uploaded.
    //
    // @param {CKEDITOR.event}
    //            evt The event object.
    function uploadFile( evt ) {
        var dialog = this.getDialog();
        var editor = dialog.getParentEditor();

        editor._.filebrowserSe = this;

        // If user didn't select the file, stop the upload.
        if ( !dialog.getContentElement( this[ 'for' ][ 0 ], this[ 'for' ][ 1 ] ).getInputElement().$.value )
            return false;

        if ( !dialog.getContentElement( this[ 'for' ][ 0 ], this[ 'for' ][ 1 ] ).getAction() )
            return false;

        return true;
    }

    // Setups the file element.
    //
    // @param {CKEDITOR.ui.dialog.file}
    //            fileInput The file element used during file upload.
    // @param {Object}
    //            filebrowser Object containing filebrowser settings assigned to
    //            the fileButton associated with this file element.
    function setupFileElement( editor, fileInput, filebrowser ) {
        var params = filebrowser.params || {};
        params.CKEditor = editor.name;
        params.CKEditorFuncNum = editor._.filebrowserFn;
        if ( !params.langCode )
            params.langCode = editor.langCode;

        fileInput.action = addQueryString( filebrowser.url, params );
        fileInput.filebrowser = filebrowser;
    }

    // Traverse through the content definition and attach filebrowser to
    // elements with 'filebrowser' attribute.
    //
    // @param String
    //            dialogName Dialog name.
    // @param {CKEDITOR.dialog.definitionObject}
    //            definition Dialog definition.
    // @param {Array}
    //            elements Array of {@link CKEDITOR.dialog.definition.content}
    //            objects.
    function attachFileBrowser( editor, dialogName, definition, elements ) {
        if ( !elements || !elements.length )
            return;

        var element, fileInput;

        for ( var i = elements.length; i--; ) {
            element = elements[ i ];

            if ( element.type == 'hbox' || element.type == 'vbox' || element.type == 'fieldset' )
                attachFileBrowser( editor, dialogName, definition, element.children );

            if ( !element.filebrowser )
                continue;

            if ( typeof element.filebrowser == 'string' ) {
                var fb = {
                    action: ( element.type == 'fileButton' ) ? 'QuickUpload' : 'Browse',
                    target: element.filebrowser
                };
                element.filebrowser = fb;
            }

            if ( element.filebrowser.action == 'Browse' ) {
                var url = element.filebrowser.url;
                if ( url === undefined ) {
                    url = editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'BrowseUrl' ];
                    if ( url === undefined )
                        url = editor.config.filebrowserBrowseUrl;
                }

                if ( url ) {
                    element.onClick = browseServer;
                    element.filebrowser.url = url;
                    element.hidden = false;
                }
            } else if ( element.filebrowser.action == 'QuickUpload' && element[ 'for' ] ) {
                url = element.filebrowser.url;
                if ( url === undefined ) {
                    url = editor.config[ 'filebrowser' + ucFirst( dialogName ) + 'UploadUrl' ];
                    if ( url === undefined )
                        url = editor.config.filebrowserUploadUrl;
                }

                if ( url ) {
                    var onClick = element.onClick;
                    element.onClick = function( evt ) {
                        // "element" here means the definition object, so we need to find the correct
                        // button to scope the event call
                        var sender = evt.sender;
                        if ( onClick && onClick.call( sender, evt ) === false )
                            return false;

                        return uploadFile.call( sender, evt );
                    };

                    element.filebrowser.url = url;
                    element.hidden = false;
                    setupFileElement( editor, definition.getContents( element[ 'for' ][ 0 ] ).get( element[ 'for' ][ 1 ] ), element.filebrowser );
                }
            }
        }
    }

    // Updates the target element with the url of uploaded/selected file.
    //
    // @param {String}
    //            url The url of a file.
    function updateTargetElement( url, sourceElement ) {
        var dialog = sourceElement.getDialog();
        var targetElement = sourceElement.filebrowser.target || null;

        // If there is a reference to targetElement, update it.
        if ( targetElement ) {
            var target = targetElement.split( ':' );
            var element = dialog.getContentElement( target[ 0 ], target[ 1 ] );
            if ( element ) {
                element.setValue( url );
                dialog.selectPage( target[ 0 ] );
            }
        }
    }

    // Returns true if filebrowser is configured in one of the elements.
    //
    // @param {CKEDITOR.dialog.definitionObject}
    //            definition Dialog definition.
    // @param String
    //            tabId The tab id where element(s) can be found.
    // @param String
    //            elementId The element id (or ids, separated with a semicolon) to check.
    function isConfigured( definition, tabId, elementId ) {
        if ( elementId.indexOf( ";" ) !== -1 ) {
            var ids = elementId.split( ";" );
            for ( var i = 0; i < ids.length; i++ ) {
                if ( isConfigured( definition, tabId, ids[ i ] ) )
                    return true;
            }
            return false;
        }

        var elementFileBrowser = definition.getContents( tabId ).get( elementId ).filebrowser;
        return ( elementFileBrowser && elementFileBrowser.url );
    }

    function setUrl( fileUrl, data ) {
        var dialog = this._.filebrowserSe.getDialog(),
            targetInput = this._.filebrowserSe[ 'for' ],
            onSelect = this._.filebrowserSe.filebrowser.onSelect;

        if ( targetInput )
            dialog.getContentElement( targetInput[ 0 ], targetInput[ 1 ] ).reset();

        if ( typeof data == 'function' && data.call( this._.filebrowserSe ) === false )
            return;

        if ( onSelect && onSelect.call( this._.filebrowserSe, fileUrl, data ) === false )
            return;

        // The "data" argument may be used to pass the error message to the editor.
        if ( typeof data == 'string' && data )
            alert( data );

        if ( fileUrl )
            updateTargetElement( fileUrl, this._.filebrowserSe );
    }

    CKEDITOR.plugins.add( 'filebrowser', {
        requires: 'popup',
        init: function( editor, pluginPath ) {
            editor._.filebrowserFn = CKEDITOR.tools.addFunction( setUrl, editor );
            editor.on( 'destroy', function() {
                CKEDITOR.tools.removeFunction( this._.filebrowserFn );
            });
        }
    });

    CKEDITOR.on( 'dialogDefinition', function( evt ) {
        // We require filebrowser plugin to be loaded.
        if ( !evt.editor.plugins.filebrowser )
            return;

        var definition = evt.data.definition,
            element;
        // Associate filebrowser to elements with 'filebrowser' attribute.
        for ( var i = 0; i < definition.contents.length; ++i ) {
            if ( ( element = definition.contents[ i ] ) ) {
                attachFileBrowser( evt.editor, evt.data.name, definition, element.elements );
                if ( element.hidden && element.filebrowser ) {
                    element.hidden = !isConfigured( definition, element[ 'id' ], element.filebrowser );
                }
            }
        }
    });

})();

/**
 * The location of an external file browser that should be launched when the **Browse Server**
 * button is pressed. If configured, the **Browse Server** button will appear in the
 * **Link**, **Image**, and **Flash** dialog windows.
 *
 * See the [File Browser/Uploader](http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_(Uploader\)) documentation.
 *
 *        config.filebrowserBrowseUrl = '/browser/browse.php';
 *
 * @since 3.0
 * @cfg {String} [filebrowserBrowseUrl='' (empty string = disabled)]
 * @member CKEDITOR.config
 */

/**
 * The location of the script that handles file uploads.
 * If set, the **Upload** tab will appear in the **Link**, **Image**,
 * and **Flash** dialog windows.
 *
 * See the [File Browser/Uploader](http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_(Uploader\)) documentation.
 *
 *        config.filebrowserUploadUrl = '/uploader/upload.php';
 *
 * @since 3.0
 * @cfg {String} [filebrowserUploadUrl='' (empty string = disabled)]
 * @member CKEDITOR.config
 */

/**
 * The location of an external file browser that should be launched when the **Browse Server**
 * button is pressed in the **Image** dialog window.
 *
 * If not set, CKEditor will use {@link CKEDITOR.config#filebrowserBrowseUrl}.
 *
 *        config.filebrowserImageBrowseUrl = '/browser/browse.php?type=Images';
 *
 * @since 3.0
 * @cfg {String} [filebrowserImageBrowseUrl='' (empty string = disabled)]
 * @member CKEDITOR.config
 */

/**
 * The location of an external file browser that should be launched when the **Browse Server**
 * button is pressed in the **Flash** dialog window.
 *
 * If not set, CKEditor will use {@link CKEDITOR.config#filebrowserBrowseUrl}.
 *
 *        config.filebrowserFlashBrowseUrl = '/browser/browse.php?type=Flash';
 *
 * @since 3.0
 * @cfg {String} [filebrowserFlashBrowseUrl='' (empty string = disabled)]
 * @member CKEDITOR.config
 */

/**
 * The location of the script that handles file uploads in the **Image** dialog window.
 *
 * If not set, CKEditor will use {@link CKEDITOR.config#filebrowserUploadUrl}.
 *
 *        config.filebrowserImageUploadUrl = '/uploader/upload.php?type=Images';
 *
 * @since 3.0
 * @cfg {String} [filebrowserImageUploadUrl='' (empty string = disabled)]
 * @member CKEDITOR.config
 */

/**
 * The location of the script that handles file uploads in the **Flash** dialog window.
 *
 * If not set, CKEditor will use {@link CKEDITOR.config#filebrowserUploadUrl}.
 *
 *        config.filebrowserFlashUploadUrl = '/uploader/upload.php?type=Flash';
 *
 * @since 3.0
 * @cfg {String} filebrowserFlashUploadUrl='' (empty string = disabled)]
 * @member CKEDITOR.config
 */

/**
 * The location of an external file browser that should be launched when the **Browse Server**
 * button is pressed in the **Link** tab of the **Image** dialog window.
 *
 * If not set, CKEditor will use {@link CKEDITOR.config#filebrowserBrowseUrl}.
 *
 *        config.filebrowserImageBrowseLinkUrl = '/browser/browse.php';
 *
 * @since 3.2
 * @cfg {String} [filebrowserImageBrowseLinkUrl='' (empty string = disabled)]
 * @member CKEDITOR.config
 */

/**
 * The features to use in the file browser popup window.
 *
 *        config.filebrowserWindowFeatures = 'resizable=yes,scrollbars=no';
 *
 * @since 3.4.1
 * @cfg {String} [filebrowserWindowFeatures='location=no,menubar=no,toolbar=no,dependent=yes,minimizable=no,modal=yes,alwaysRaised=yes,resizable=yes,scrollbars=yes']
 * @member CKEDITOR.config
 */

/**
 * The width of the file browser popup window. It can be a number denoting a value in
 * pixels or a percent string.
 *
 *        config.filebrowserWindowWidth = 750;
 *
 *        config.filebrowserWindowWidth = '50%';
 *
 * @cfg {Number/String} [filebrowserWindowWidth='80%']
 * @member CKEDITOR.config
 */

/**
 * The height of the file browser popup window. It can be a number denoting a value in
 * pixels or a percent string.
 *
 *        config.filebrowserWindowHeight = 580;
 *
 *        config.filebrowserWindowHeight = '50%';
 *
 * @cfg {Number/String} [filebrowserWindowHeight='70%']
 * @member CKEDITOR.config
 */

причеплено у view:

Прихований текст
 <script type="text/javascript" src="{{=URL('static', 'ckeditor/ckeditor.js')}}"></script>
    <script>jQuery('#page_content').css('width','800px').css('height','50px');</script>
{{pass}}
<script>
    CKEDITOR.replace( 'content', {
                    filebrowserUploadUrl: "{{=URL('images', 'nicedit_image_upload', args=request.args(0))}}"
                     });
</script>

редагування  чудово працює.
далі є потреба вставити на сторінку зображення.
для цього треба сам файл з картинкою завантажити на сервер. ckeditor цього не може зробити - він може лише вибрати файл на локальному компі і якось передати його контролеру на сервері, котрий уже помістить у відповідний каталог.
в моєму випадку таким контролером є images/nicedit_image_upload

Прихований текст
def nicedit_image_upload():
    """
    Controller to upload images with nicedit
    """
    from gluon.contrib.simplejson import dumps
    from os import mkdir
    
    page_id = request.args(0)
    pathname = path.join(request.folder,'static','images', 'pages_content', page_id)
    if not path.exists(pathname):
        mkdir(pathname)

    pathfilename = path.join(pathname, request.vars.image.filename)
    path_th_filename = path.join(pathname, 'th_', request.vars.image.filename)
    dest_file = open(pathfilename, 'wb')
    
    try:
        dest_file.write(request.vars.image.file.read())
    finally:
        dest_file.close()

    #Make a thumbnail (max 800*500px) of the uploaded Image
    try:
        from PIL import Image
        im = Image.open(pathfilename)
        im.thumbnail((800,500),Image.ANTIALIAS)
        im.save(path_th_filename)
    except:
        pass
    links_dict = {"original":URL('static', 'images/pages_content/'+page_id+'/'+request.vars.image.filename)}
    set_dict = {"links" : links_dict}
    upload_dict = {"upload" : set_dict}

    return dumps(upload_dict)

залишилося передати контролеру ще і сам об’єкт, який треба завантажити.
як???? перечитав десятки хелпів/манів , в голові повна каша...

26 Востаннє редагувалося Singularity (27.12.2013 15:44:09)

Re: Python - запитання

Здається в папкі з ckeditor`ом повинен бути файл типу ckeditor/config.js в якому потрібно дописати

CKEDITOR.editorConfig = function( config )
{
     config.filebrowserUploadUrl = '/uploader/upload.php';
};

27 Востаннє редагувалося ping (27.12.2013 16:21:22)

Re: Python - запитання

Singularity написав:

Здається в папкі з ckeditor`ом повинен бути файл типу ckeditor/config.js в якому потрібно дописати

CKEDITOR.editorConfig = function( config )
{
     config.filebrowserUploadUrl = '/uploader/upload.php';
};

поставив версію CKEDITOR уже з цим плагіном (standart):

Прихований текст
/**
 * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 */

// Compressed version of core/ckeditor_base.js. See original for instructions.
/*jsl:ignore*/
window.CKEDITOR||(window.CKEDITOR=function(){var l=Math.floor(900*Math.random())+100,b=window.CKEDITOR_BASEPATH||"";if(!b)for(var g=document.getElementsByTagName("script"),e=0;e<g.length;e++){var h=g[e].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i);if(h){b=h[1];break}}-1==b.indexOf(":/")&&(b=0===b.indexOf("/")?location.href.match(/^.*?:\/\/[^\/]*/)[0]+b:location.href.match(/^[^\?]*\/(?:)/)[0]+b);if(!b)throw'The CKEditor installation path could not be automatically detected. Please set the global variable "CKEDITOR_BASEPATH" before creating editor instances.';var c=function(){try{document.addEventListener?(document.removeEventListener("DOMContentLoaded",c,!1),j()):document.attachEvent&&"complete"===document.readyState&&(document.detachEvent("onreadystatechange",c),j())}catch(a){}},j=function(){for(var a;a=f.shift();)a()},f=[],d={timestamp:"",version:"%VERSION%",revision:"%REV%",rnd:l,_:{pending:[]},status:"unloaded",basePath:b,getUrl:function(a){-1==a.indexOf(":/")&&0!==a.indexOf("/")&&(a=this.basePath+a);this.timestamp&&("/"!=a.charAt(a.length-1)&&!/[&?]t=/.test(a))&&(a+=(0<=a.indexOf("?")?"&":"?")+"t="+this.timestamp);return a},domReady:function(a){f.push(a);"complete"===document.readyState&&setTimeout(c,1);if(1==f.length)if(document.addEventListener)document.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1);else if(document.attachEvent){document.attachEvent("onreadystatechange",c);window.attachEvent("onload",c);a=!1;try{a=!window.frameElement}catch(b){}if(document.documentElement.doScroll&&a){var d=function(){try{document.documentElement.doScroll("left")}catch(a){setTimeout(d,1);return}c()};d()}}}},k=window.CKEDITOR_GETURL;if(k){var m=d.getUrl;d.getUrl=function(a){return k.call(d,a)||m.call(d,a)}}return d}());
/*jsl:end*/

if ( CKEDITOR.loader )
    CKEDITOR.loader.load( 'ckeditor' );
else {
    // Set the script name to be loaded by the loader.
    CKEDITOR._autoLoad = 'ckeditor';

    // Include the loader script.
    if ( document.body && ( !document.readyState || document.readyState == 'complete' ) ) {
        var script = document.createElement( 'script' );
        script.type = 'text/javascript';
        script.src = CKEDITOR.getUrl( 'core/loader.js' );
        document.body.appendChild( script );
    } else {
        document.write( '<script type="text/javascript" src="' + CKEDITOR.getUrl( 'core/loader.js' ) + '"></script>' );
    }
}

/**
 * The skin to load for all created instances, it may be the name of the skin
 * folder inside the editor installation path, or the name and the path separated
 * by a comma.
 *
 * **Note:** This is a global configuration that applies to all instances.
 *
 *        CKEDITOR.skinName = 'moono';
 *
 *        CKEDITOR.skinName = 'myskin,/customstuff/myskin/';
 *
 * @cfg {String} [skinName='moono']
 * @member CKEDITOR
 */
CKEDITOR.skinName = 'moono';

в конфіг включено "з коробки":

Прихований текст
/**
 * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md or http://ckeditor.com/license
 */

CKEDITOR.editorConfig = function( config ) {
    
    // %REMOVE_START%
    // The configuration options below are needed when running CKEditor from source files.
    config.plugins = 'dialogui,dialog,about,a11yhelp,basicstyles,blockquote,clipboard,panel,floatpanel,menu,contextmenu,resize,button,toolbar,elementspath,enterkey,entities,popup,filebrowser,floatingspace,listblock,richcombo,format,horizontalrule,htmlwriter,wysiwygarea,image,indent,indentlist,fakeobjects,link,list,magicline,maximize,pastetext,pastefromword,removeformat,sourcearea,specialchar,menubutton,scayt,stylescombo,tab,table,tabletools,undo,wsc';
    config.skin = 'kama';
    // %REMOVE_END%

    // Define changes to default configuration here.
    // For the complete reference:
    // http://docs.ckeditor.com/#!/api/CKEDITOR.config

    // The toolbar groups arrangement, optimized for two toolbar rows.
    config.toolbarGroups = [
        { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },
        { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },
        { name: 'links' },
        { name: 'insert' },
        { name: 'forms' },
        { name: 'tools' },
        { name: 'document',       groups: [ 'mode', 'document', 'doctools' ] },
        { name: 'others' },
        '/',
        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
        { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },
        { name: 'styles' },
        { name: 'colors' },
        { name: 'about' }
    ];

    // Remove some buttons, provided by the standard plugins, which we don't
    // need to have in the Standard(s) toolbar.
    config.removeButtons = 'Underline,Subscript,Superscript';

    // Se the most common block elements.
    config.format_tags = 'p;h1;h2;h3;pre';

    // Make dialogs simpler.
    config.removeDialogTabs = 'image:advanced;link:advanced';
};

28

Re: Python - запитання

Усім привіт.
Зіткнувся з такою проблемою:
Якщо хто працював з netinfo, будь ласка, пыдскажіть де можна знайти інфо, або посібник, як з ним працювати. Конкретно, є завдання:

Прихований текст

Create functionality which sends ping requests to "8.8.8.8" host out of the default network interface in
the system (usually something like 'ethX', where X is number) and verifies that the requests have been
sent by capturing outgoing packets.
Do the same for 'lo' and 'ethX' interfaces simultaneously (use standard 'threading' module).
Captured results should be collected into dictionary which has the following structure:
{'iface1': list_of_captured_packets, 'iface2': list_of_captured_packets, ...}
Modification of this dictionary should be thread-safe.
Modify the test class by adding a test which checks that resulting dictionary contains both - 'lo' and
'ethX' interfaces as keys.

Потрібно написати скрипт на Python 2.5+, використовуючи "scapy" i "netinfo". Зі "scapy" я розібрався, пинг написав, але з інтерфейсами... Якщо хтось може підсказати ресурс з інформацією, або пояснити як працювати з "netinfo", буду дуже вдячний!

29

Re: Python - запитання

Привіт,
Вдалось Вам козаки комусь зробити це завдання для торок?
Поділіться будь-ласка як Ви то робили.
А то я альфабет в пітоні, тільки закінчив книжку Джоша КОгліаті - нон=програмерс гайд фор пайтон.