Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions 6 docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
# documentation root, use Path(...).absolute() to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
from pathlib import Path
sys.path.insert(0, str(Path('..').absolute()))
zliang-akamai marked this conversation as resolved.
Show resolved Hide resolved


# -- Project information -----------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions 8 linode_api4/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from dataclasses import dataclass
from pathlib import Path

from linode_api4.objects import JSONObject

Expand Down Expand Up @@ -47,9 +47,9 @@ def load_and_validate_keys(authorized_keys):
ret.append(k)
else:
# it doesn't appear to be a key.. is it a path to the key?
k = os.path.expanduser(k)
if os.path.isfile(k):
with open(k) as f:
k_path = Path(k).expanduser()
if k_path.is_file():
with open(k_path) as f:
ret.append(f.read().rstrip())
zliang-akamai marked this conversation as resolved.
Show resolved Hide resolved
else:
raise ValueError(
Expand Down
7 changes: 4 additions & 3 deletions 7 linode_api4/groups/linode.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import base64
import os
from pathlib import Path
from typing import Any, Dict, List, Optional, Union

from linode_api4.common import load_and_validate_keys
Expand Down Expand Up @@ -457,8 +457,9 @@ def stackscript_create(
script_body = script
if not script.startswith("#!"):
# it doesn't look like a stackscript body, let's see if it's a file
if os.path.isfile(script):
with open(script) as f:
script_path = Path(script)
if script_path.is_file():
with open(script_path) as f:
script_body = f.read()
zliang-akamai marked this conversation as resolved.
Show resolved Hide resolved
else:
raise ValueError(
Expand Down
8 changes: 4 additions & 4 deletions 8 linode_api4/groups/profile.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from datetime import datetime
from pathlib import Path

from linode_api4 import UnexpectedResponseError
from linode_api4.common import SSH_KEY_TYPES
Expand Down Expand Up @@ -322,9 +322,9 @@ def ssh_key_upload(self, key, label):
"""
if not key.startswith(SSH_KEY_TYPES):
# this might be a file path - look for it
path = os.path.expanduser(key)
if os.path.isfile(path):
with open(path) as f:
key_path = Path(key).expanduser()
if key_path.is_file():
with open(key_path) as f:
key = f.read().strip()
zliang-akamai marked this conversation as resolved.
Show resolved Hide resolved
if not key.startswith(SSH_KEY_TYPES):
raise ValueError("Invalid SSH Public Key")
Expand Down
12 changes: 7 additions & 5 deletions 12 linode_api4/objects/nodebalancer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from pathlib import Path
from urllib import parse

from linode_api4.common import Price, RegionPrice
Expand Down Expand Up @@ -220,12 +220,14 @@ def load_ssl_data(self, cert_file, key_file):

# we're disabling warnings here because these attributes are defined dynamically
# through linode.objects.Base, and pylint isn't privy
if os.path.isfile(os.path.expanduser(cert_file)):
with open(os.path.expanduser(cert_file)) as f:
cert_path = Path(cert_file).expanduser()
if cert_path.is_file():
with open(cert_path) as f:
self.ssl_cert = f.read()

if os.path.isfile(os.path.expanduser(key_file)):
with open(os.path.expanduser(key_file)) as f:
key_path = Path(key_file).expanduser()
if key_path.is_file():
with open(key_path) as f:
self.ssl_key = f.read()


Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.