File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -319,11 +319,15 @@ def create_artifact(
319319 shutil .move (artifact_path_tmp , artifact_path )
320320
321321
322+ def ensure_can_create_torrent () -> None :
323+ if torf is None :
324+ raise ImportError ("nimp require the 'torrent' extra dependency to handle torrent creation" )
325+
326+
322327def create_torrent (artifact_path : StrPathLike , announce : str | None , dry_run : bool ) -> None :
323328 '''Create a torrent for an existing artifact'''
324329
325- if torf is None :
326- raise ImportError ("nimp require the 'torrent' extra dependency to handle torrent creation" )
330+ ensure_can_create_torrent ()
327331
328332 artifact_path = Path (artifact_path )
329333
Original file line number Diff line number Diff line change 2727import shutil
2828import zipfile
2929
30- import nimp .command
3130import nimp .artifacts
31+ import nimp .command
3232
3333
3434def _try_remove (file_path , dry_run ):
@@ -59,9 +59,8 @@ def is_available(self, env):
5959 return True , ''
6060
6161 def run (self , env ):
62- if env .torrent and nimp .system .try_import ('BitTornado' ) is None :
63- logging .error ('Failed to import BitTornado module (required for torrent option)' )
64- return False
62+ if env .torrent :
63+ nimp .artifacts .ensure_can_create_torrent ()
6564
6665 if env .torrent and not hasattr (env , 'torrent_tracker_announce' ):
6766 env .torrent_tracker_announce = None
You can’t perform that action at this time.
0 commit comments