chipfoundry-cli 0.1.4__tar.gz → 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: chipfoundry-cli
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: CLI tool to automate ChipFoundry project submission to SFTP server
5
5
  Home-page: https://chipfoundry.io
6
6
  License: Apache-2.0
@@ -48,6 +48,8 @@ def config_cmd():
48
48
  key_path = console.input("Enter path to your SFTP private key (leave blank for ~/.ssh/id_rsa): ").strip()
49
49
  if not key_path:
50
50
  key_path = os.path.expanduser('~/.ssh/id_rsa')
51
+ else:
52
+ key_path = os.path.abspath(os.path.expanduser(key_path))
51
53
  config = {
52
54
  "sftp_username": username,
53
55
  "sftp_key": key_path,
@@ -143,7 +145,9 @@ def push(project_root, sftp_host, sftp_username, sftp_key, sftp_password, projec
143
145
  key_path = sftp_key
144
146
  password = sftp_password
145
147
  # Always resolve key_path to absolute path if set
148
+ print(f"key_path: {key_path}")
146
149
  if key_path:
150
+ print(f"key_path: {key_path}")
147
151
  key_path = os.path.abspath(os.path.expanduser(key_path))
148
152
  if not key_path and not password:
149
153
  if os.path.exists(DEFAULT_SSH_KEY):
@@ -104,13 +104,30 @@ def update_or_create_project_json(
104
104
  save_project_json(project_json_path, data)
105
105
  return project_json_path
106
106
 
107
+ def load_private_key(key_path, password=None):
108
+ key_loaders = [
109
+ paramiko.Ed25519Key.from_private_key_file,
110
+ paramiko.RSAKey.from_private_key_file,
111
+ paramiko.ECDSAKey.from_private_key_file,
112
+ paramiko.DSSKey.from_private_key_file,
113
+ ]
114
+ last_exception = None
115
+ for loader in key_loaders:
116
+ try:
117
+ return loader(key_path, password=password)
118
+ except paramiko.ssh_exception.PasswordRequiredException:
119
+ raise # Key is encrypted, need password
120
+ except Exception as e:
121
+ last_exception = e
122
+ raise RuntimeError(f"Could not load private key: {last_exception}")
123
+
107
124
  def sftp_connect(host: str, username: str, password: str = None, key_path: str = None):
108
125
  """
109
126
  Establish an SFTP connection using paramiko. Returns an SFTP client.
110
127
  """
111
128
  transport = paramiko.Transport((host, 22))
112
129
  if key_path:
113
- private_key = paramiko.RSAKey.from_private_key_file(key_path)
130
+ private_key = load_private_key(key_path)
114
131
  transport.connect(username=username, pkey=private_key)
115
132
  else:
116
133
  transport.connect(username=username, password=password)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "chipfoundry-cli"
3
- version = "0.1.4"
3
+ version = "0.1.6"
4
4
  description = "CLI tool to automate ChipFoundry project submission to SFTP server"
5
5
  authors = ["ChipFoundry <marwan.abbas@chipfoundry.io>"]
6
6
  readme = "README.md"
File without changes