File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -489,6 +489,30 @@ def omcpath(self, *path) -> OMCPath:
489489
490490 return OMCPath (* path , session = self )
491491
492+ def omcpath_tempdir (self ) -> OMCPath :
493+ """
494+ Get a temporary directory using OMC.
495+ """
496+ names = [str (uuid .uuid4 ()) for _ in range (100 )]
497+
498+ tempdir_str = self .sendExpression ("getTempDirectoryPath()" )
499+ tempdir_base = self .omcpath (tempdir_str )
500+ tempdir : Optional [OMCPath ] = None
501+ for name in names :
502+ # create a unique temporary directory name
503+ tempdir = tempdir_base / name
504+
505+ if tempdir .exists ():
506+ continue
507+
508+ tempdir .mkdir (parents = True , exist_ok = False )
509+ break
510+
511+ if tempdir is None or not tempdir .is_dir ():
512+ raise OMCSessionException ("Cannot create a temporary directory!" )
513+
514+ return tempdir
515+
492516 def execute (self , command : str ):
493517 warnings .warn ("This function is depreciated and will be removed in future versions; "
494518 "please use sendExpression() instead" , DeprecationWarning , stacklevel = 2 )
You can’t perform that action at this time.
0 commit comments