Importing Login Configuration Text FIle In Python











up vote
0
down vote

favorite












I'm new to Python, looked unsuccessfully for answers in previous posts. Hoping you can help me.



I'm trying to use a script I copied off of this blog post.



Said script automates the process of starting SSH sessions on a given remote system and running commands on that system.



It imports a configuration file, from the import statement below I assume named conf, that supplies the script with login credentials, file paths, etc.



from conf import ssh_conf as conf_file


My issue is I am not sure how the conf file is formatted and it wasn't provided in the blog post. From the import statement I assume the file is named conf.py and the it has sections, one of them named ssh_conf



Can anyone describe how was that file formatted?



Gratefully,



A Python Newbie.










share|improve this question




























    up vote
    0
    down vote

    favorite












    I'm new to Python, looked unsuccessfully for answers in previous posts. Hoping you can help me.



    I'm trying to use a script I copied off of this blog post.



    Said script automates the process of starting SSH sessions on a given remote system and running commands on that system.



    It imports a configuration file, from the import statement below I assume named conf, that supplies the script with login credentials, file paths, etc.



    from conf import ssh_conf as conf_file


    My issue is I am not sure how the conf file is formatted and it wasn't provided in the blog post. From the import statement I assume the file is named conf.py and the it has sections, one of them named ssh_conf



    Can anyone describe how was that file formatted?



    Gratefully,



    A Python Newbie.










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm new to Python, looked unsuccessfully for answers in previous posts. Hoping you can help me.



      I'm trying to use a script I copied off of this blog post.



      Said script automates the process of starting SSH sessions on a given remote system and running commands on that system.



      It imports a configuration file, from the import statement below I assume named conf, that supplies the script with login credentials, file paths, etc.



      from conf import ssh_conf as conf_file


      My issue is I am not sure how the conf file is formatted and it wasn't provided in the blog post. From the import statement I assume the file is named conf.py and the it has sections, one of them named ssh_conf



      Can anyone describe how was that file formatted?



      Gratefully,



      A Python Newbie.










      share|improve this question















      I'm new to Python, looked unsuccessfully for answers in previous posts. Hoping you can help me.



      I'm trying to use a script I copied off of this blog post.



      Said script automates the process of starting SSH sessions on a given remote system and running commands on that system.



      It imports a configuration file, from the import statement below I assume named conf, that supplies the script with login credentials, file paths, etc.



      from conf import ssh_conf as conf_file


      My issue is I am not sure how the conf file is formatted and it wasn't provided in the blog post. From the import statement I assume the file is named conf.py and the it has sections, one of them named ssh_conf



      Can anyone describe how was that file formatted?



      Gratefully,



      A Python Newbie.







      python file import configuration automation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 22 at 15:28









      Ali AzG

      607515




      607515










      asked Nov 22 at 15:24









      Rakesh Mohan

      12




      12
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          There are not really sections like that.



          If conf.py was a file, then this could be made to work, by making ssh_conf a class within conf.py:



          class ssh_conf():
          HOST="www.example.com"


          But that's kind of nasty and feels like pointless abuse of classes.



          My guess is that conf is actually a package. That is to say, a directory called conf containing a (empty) file called __init__.py and a number of other files, any of which can be imported from conf. One of these files would be called ssh_conf.py and that would contain things like:



          HOST="www.example.com"


          The overall structure looks like:



          MyProject/
          |-- my_application.py
          `-- conf/
          |-- __init__.py
          `-- ssh_conf.py


          If you aren't familiar with packages, the official documentation is a good place to start.






          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434065%2fimporting-login-configuration-text-file-in-python%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            There are not really sections like that.



            If conf.py was a file, then this could be made to work, by making ssh_conf a class within conf.py:



            class ssh_conf():
            HOST="www.example.com"


            But that's kind of nasty and feels like pointless abuse of classes.



            My guess is that conf is actually a package. That is to say, a directory called conf containing a (empty) file called __init__.py and a number of other files, any of which can be imported from conf. One of these files would be called ssh_conf.py and that would contain things like:



            HOST="www.example.com"


            The overall structure looks like:



            MyProject/
            |-- my_application.py
            `-- conf/
            |-- __init__.py
            `-- ssh_conf.py


            If you aren't familiar with packages, the official documentation is a good place to start.






            share|improve this answer

























              up vote
              0
              down vote













              There are not really sections like that.



              If conf.py was a file, then this could be made to work, by making ssh_conf a class within conf.py:



              class ssh_conf():
              HOST="www.example.com"


              But that's kind of nasty and feels like pointless abuse of classes.



              My guess is that conf is actually a package. That is to say, a directory called conf containing a (empty) file called __init__.py and a number of other files, any of which can be imported from conf. One of these files would be called ssh_conf.py and that would contain things like:



              HOST="www.example.com"


              The overall structure looks like:



              MyProject/
              |-- my_application.py
              `-- conf/
              |-- __init__.py
              `-- ssh_conf.py


              If you aren't familiar with packages, the official documentation is a good place to start.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                There are not really sections like that.



                If conf.py was a file, then this could be made to work, by making ssh_conf a class within conf.py:



                class ssh_conf():
                HOST="www.example.com"


                But that's kind of nasty and feels like pointless abuse of classes.



                My guess is that conf is actually a package. That is to say, a directory called conf containing a (empty) file called __init__.py and a number of other files, any of which can be imported from conf. One of these files would be called ssh_conf.py and that would contain things like:



                HOST="www.example.com"


                The overall structure looks like:



                MyProject/
                |-- my_application.py
                `-- conf/
                |-- __init__.py
                `-- ssh_conf.py


                If you aren't familiar with packages, the official documentation is a good place to start.






                share|improve this answer












                There are not really sections like that.



                If conf.py was a file, then this could be made to work, by making ssh_conf a class within conf.py:



                class ssh_conf():
                HOST="www.example.com"


                But that's kind of nasty and feels like pointless abuse of classes.



                My guess is that conf is actually a package. That is to say, a directory called conf containing a (empty) file called __init__.py and a number of other files, any of which can be imported from conf. One of these files would be called ssh_conf.py and that would contain things like:



                HOST="www.example.com"


                The overall structure looks like:



                MyProject/
                |-- my_application.py
                `-- conf/
                |-- __init__.py
                `-- ssh_conf.py


                If you aren't familiar with packages, the official documentation is a good place to start.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 at 16:52









                Rob Bricheno

                2,280218




                2,280218






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434065%2fimporting-login-configuration-text-file-in-python%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    What visual should I use to simply compare current year value vs last year in Power BI desktop

                    Alexandru Averescu

                    Trompette piccolo