{"id":92,"date":"2014-03-14T13:44:00","date_gmt":"2014-03-14T10:44:00","guid":{"rendered":"http:\/\/blog.successionua.com\/?p=92"},"modified":"2014-03-14T13:44:00","modified_gmt":"2014-03-14T10:44:00","slug":"%d0%be%d0%bf%d1%80%d0%b5%d0%b4%d0%b5%d0%bb%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b8-%d0%b2%d1%8b%d0%b7%d0%be%d0%b2-fabric-task-%d0%b2-%d0%be%d0%b4%d0%bd%d0%be%d0%bc-python-%d1%81%d0%ba%d1%80%d0%b8%d0%bf%d1%82","status":"publish","type":"post","link":"https:\/\/geckich.space\/?p=92","title":{"rendered":"\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u0437\u043e\u0432 fabric task \u0432 \u043e\u0434\u043d\u043e\u043c Python \u0441\u043a\u0440\u0438\u043f\u0442\u0435"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 fabric \u0434\u043b\u044f Python \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 (\u0430\u0434\u043c\u0438\u043d\u0438\u043c\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, deployment \u0438 \u0442. \u0434.) \u0434\u043b\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u041e\u0421 Linux. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b open ssh \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 <a href=\"http:\/\/docs.fabfile.org\/en\/latest\/index.html\" target=\"_blank\" rel=\"noopener noreferrer\">\u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435<\/a> \u0438\u043b\u0438 <a href=\"http:\/\/www.pythonforbeginners.com\/systems-programming\/how-to-use-fabric-in-python\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>\u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0438 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0442\u0430\u0441\u043a \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 fabric \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043a\u0440\u0438\u043f\u0442\u0430:<\/p>\n<div style=\"background: #202020; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #999999; font-style: italic;\">#!\/usr\/bin\/env python<\/span><br \/><span style=\"color: #999999; font-style: italic;\"># Script dependencies: python-devel, fabric (https:\/\/github.com\/fabric\/fabric\/archive\/master.zip)<\/span><br \/><span style=\"color: #999999; font-style: italic;\"># Usage: python script.py<\/span><br \/><span style=\"color: #6ab825; font-weight: bold;\">import<\/span> <span style=\"color: #447fcf; text-decoration: underline;\">fabric<\/span><br \/><span style=\"color: #6ab825; font-weight: bold;\">from<\/span> <span style=\"color: #447fcf; text-decoration: underline;\">fabric.api<\/span> <span style=\"color: #6ab825; font-weight: bold;\">import<\/span> <span style=\"color: #d0d0d0;\">*<\/span><br \/><span style=\"color: #999999; font-style: italic;\"># Define ssh-like address user@server_hostname<\/span><br \/><span style=\"color: #d0d0d0;\">remote_host<\/span> <span style=\"color: #d0d0d0;\">=<\/span> <span style=\"color: #d0d0d0;\">user<\/span><span style=\"color: orange;\">@server<\/span><br \/><br \/><span style=\"color: #6ab825; font-weight: bold;\">def<\/span> <span style=\"color: #447fcf;\">some_fab_task<\/span><span style=\"color: #d0d0d0;\">():<\/span><br \/>    <span style=\"color: #999999; font-style: italic;\"># Define fabric task here<\/span><br \/>    <span style=\"color: #999999; font-style: italic;\"># hide('everything') helps to execute task with minimum output to console<\/span><br \/>    <span style=\"color: #6ab825; font-weight: bold;\">with<\/span> <span style=\"color: #d0d0d0;\">settings(hide(<\/span><span style=\"color: #ed9d13;\">'everything'<\/span><span style=\"color: #d0d0d0;\">)):<\/span><br \/>        <span style=\"color: #6ab825; font-weight: bold;\">try<\/span><span style=\"color: #d0d0d0;\">:<\/span><br \/>           <span style=\"color: #d0d0d0;\">....<\/span><br \/>        <span style=\"color: #6ab825; font-weight: bold;\">except<\/span><span style=\"color: #d0d0d0;\">:<\/span><br \/>           <span style=\"color: #d0d0d0;\">....<\/span><br \/><br \/><span style=\"color: #999999; font-style: italic;\"># Main function<\/span><br \/><span style=\"color: #6ab825; font-weight: bold;\">if<\/span> <span style=\"color: #d0d0d0;\">__name__<\/span> <span style=\"color: #d0d0d0;\">==<\/span> <span style=\"color: #ed9d13;\">'__main__'<\/span><span style=\"color: #d0d0d0;\">:<\/span><br \/>    <span style=\"color: #999999; font-style: italic;\"># Call fabric task from here<\/span><br \/>    <span style=\"color: #d0d0d0;\">fabric.tasks.execute(some_fab_task,<\/span> <span style=\"color: #d0d0d0;\">hosts=[remote_host])<\/span><br \/><\/pre>\n<\/div>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043a\u0440\u0438\u043f\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0441\u044f &#8220;\u0442\u0438\u0445\u043e&#8221; &#8211; \u0431\u0435\u0437 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0432\u0432\u043e\u0434 \u043f\u0430\u0440\u043e\u043b\u044f \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043d\u0430 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e ssh-\u043a\u043b\u044e\u0447\u0435\u0439,&nbsp;&nbsp;\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u043a \u044f \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u043b&nbsp;<a href=\"http:\/\/geckich.blogspot.com\/2011\/09\/ssh-rsa.html\" target=\"_blank\" rel=\"noopener noreferrer\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/p>\n<p>Update:<\/p>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u043a\u0440\u0438\u043f\u0442, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u0438\u0445 <b>\u043f\u0435\u0440\u0435\u0434<\/b> hosts=.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #202020; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #d0d0d0;\">fabric.tasks.execute(some_fab_task,<\/span> <span style=\"color: #d0d0d0;\">arg1,<\/span> <span style=\"color: #d0d0d0;\">arg2,<\/span> <span style=\"color: #d0d0d0;\">hosts=[remote_host])<\/span><br \/><\/pre>\n<\/div>\n<p>\u0414\u043b\u044f \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 xargs, \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0438\u0445 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e \u0438\u043b\u0438 \u043f\u043e\u0441\u043b\u0435 hosts=<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #202020; border-width: .1em .1em .1em .8em; border: solid gray; overflow: auto; padding: .2em .6em; width: auto;\">\n<pre style=\"line-height: 125%; margin: 0;\"><span style=\"color: #d0d0d0;\">fabric.tasks.execute(some_fab_task,<\/span> <span style=\"color: #d0d0d0;\">arg1,<\/span> <span style=\"color: #d0d0d0;\">arg2,<\/span> <span style=\"color: #d0d0d0;\">hosts=[remote_host],<\/span> <span style=\"color: #d0d0d0;\">xarg1=value1)<\/span><br \/><\/pre>\n<\/div>\n<\/div>\n<div>http:\/\/geckich.blogspot.com\/<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 fabric \u0434\u043b\u044f Python \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 (\u0430\u0434\u043c\u0438\u043d\u0438\u043c\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, deployment \u0438 \u0442. \u0434.) \u0434\u043b\u044f \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u0432 \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u041e\u0421 Linux. \u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b open ssh \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u043d\u0430 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u043c \u0441\u0430\u0439\u0442\u0435 \u0438\u043b\u0438 \u0437\u0434\u0435\u0441\u044c. \u0411\u044b\u0432\u0430\u044e\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u043e\u0434\u043d\u043e\u043c \u0441\u043a\u0440\u0438\u043f\u0442\u0435 \u0438 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u0442\u0430\u0441\u043a \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 &hellip; <a href=\"https:\/\/geckich.space\/?p=92\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u0432\u044b\u0437\u043e\u0432 fabric task \u0432 \u043e\u0434\u043d\u043e\u043c Python \u0441\u043a\u0440\u0438\u043f\u0442\u0435<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10,11],"tags":[],"class_list":["post-92","post","type-post","status-publish","format-standard","hentry","category-linux","category-programming"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts\/92","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=92"}],"version-history":[{"count":0,"href":"https:\/\/geckich.space\/index.php?rest_route=\/wp\/v2\/posts\/92\/revisions"}],"wp:attachment":[{"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=92"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=92"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geckich.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=92"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}