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.
python file import configuration automation
add a comment |
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.
python file import configuration automation
add a comment |
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.
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 at 15:28
Ali AzG
607515
607515
asked Nov 22 at 15:24
Rakesh Mohan
12
12
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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 at 16:52
Rob Bricheno
2,280218
2,280218
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.
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.
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