summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2024-02-13 01:26:42 +0100
committeremkael <emkael@tlen.pl>2024-02-13 01:26:42 +0100
commit1e241f2be87b740d3135291bf2c40db5bcf50171 (patch)
tree2ca0728228eb6994b47274e90840b2048337af6c
parent3c44a072bd3833c34fa6c15553cce0594247aa9d (diff)
Temp .bigdealrc file creation
-rw-r--r--squaredeal/__init__.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/squaredeal/__init__.py b/squaredeal/__init__.py
index 8ed571f..3c38a5b 100644
--- a/squaredeal/__init__.py
+++ b/squaredeal/__init__.py
@@ -122,6 +122,15 @@ class SquareDeal(object):
self.sqd.tofile(self.sqd_file)
+ def _ensure_rcfile(self, rcfile_path):
+ if os.path.isfile(rcfile_path):
+ return True
+ with open(rcfile_path, 'w') as rcfile:
+ rcfile.write('[BigDeal]\n')
+ rcfile.write('formats=pbn\n')
+ rcfile.write('askformats=no\n')
+ rcfile.write('owner=PySquareDeal\n')
+
def generate(self, phase, session, reserve=False, **kwargs):
if not SquareDeal.BIGDEALX_PATH:
raise SquareDealError('Path to BigDeal is not set, initialize SquareDeal.BIGDEALX_PATH value')
@@ -153,9 +162,12 @@ class SquareDeal(object):
'-e', reserve_info,
'-p', phase.output_file_name(session+1, reserve),
'-n', board_ranges[session]]
+ working_dir = os.path.realpath(os.path.dirname(self.sqd.sqd_path)) if self.sqd.sqd_path else None
+ rcfile_path = os.path.join(working_dir or '', '.bigdealrc')
+ rcfile_exists = self._ensure_rcfile(rcfile_path)
subprocess.run(
- args,
- cwd=os.path.realpath(os.path.dirname(self.sqd.sqd_path)) if self.sqd.sqd_path else None,
- capture_output=True, check=True)
+ args, cwd=working_dir, capture_output=True, check=True)
+ if not rcfile_exists:
+ os.unlink(rcfile_path)
except subprocess.CalledProcessError as ex:
raise SquareDealError('BigDeal invocation failed: %s' % (ex.stderr))