Importing Login Configuration Text FIle In Python
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
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
add a comment |
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
add a comment |
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
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
python file import configuration automation
edited Nov 22 '18 at 15:28
Ali AzG
7411717
7411717
asked Nov 22 '18 at 15:24
Rakesh MohanRakesh Mohan
12
12
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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.
add a comment |
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',
autoActivateHeartbeat: false,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 22 '18 at 16:52
Rob BrichenoRob Bricheno
2,489420
2,489420
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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