Skip to content

Commit 977f589

Browse files
Merge pull request #34 from ModuloFS/main
New feature selectable local export location
2 parents df07c7c + 7618f2d commit 977f589

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ In order to speed up the development to production process we support the automa
4343
![Attribute list for MPNs](docs/mpn_assign.png)
4444

4545
### How to export data locally
46-
Due to company-wide firewall restrictions etc. the direct upload may not work. For this case it's possible to export all data locally as a ZIP file. This file can then be uploaded manually.
47-
To enable this option, open the "Board Setup", select "Text Variables" and add a new variable called "aisler_export_locally". The value itself doesn't matter. Now this is set the plugin will place a ZIP file next to the kicad_pcb file instead of uploading the file directly.
46+
Due to company-wide firewall restrictions, direct upload may not work. In this case, it is possible to export all data locally as a ZIP file, which can then be uploaded manually.
47+
To enable this option, open the "Board Setup", select "Text Variables", and add a new variable called "aisler_export_locally". The value itself does not matter. Once this is set, the plugin will place a ZIP file next to the kicad_pcb file instead of uploading it directly.
48+
If you want to specify a custom location for the local export relative to the project directory, you can add another text variable called "aisler_local_export_path". The value of this variable specifies the target directory relative to your project location.
49+
If it is left empty, the plugin will place the ZIP file next to the kicad_pcb file. If you enter "\Fabrication", for example, the plugin will create a folder called "Fabrication" next to the kicad_pcb file and place the ZIP file in that folder.
4850

4951
### About AISLER
5052
AISLER makes hardware less hard by providing simple electronics manufacturing for everyone. We are based in Europe and focus on amazingly affordable prices, super swift delivery and outstanding customer support. We are KiCad Platinum Sponsor as we donate a significant amount of our revenues made from KiCad designs back to the project.

pcm/metadata_template.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"versions": [
3030
{
31-
"version": "0.2.3",
31+
"version": "0.2.4",
3232
"status": "stable",
3333
"kicad_version": "8.00"
3434
}

src/push_thread.py

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ def __init__(self, wxObject):
2020

2121
def run(self):
2222
temp_dir = tempfile.mkdtemp()
23-
_, temp_file = tempfile.mkstemp()
23+
fd, temp_file = tempfile.mkstemp()
24+
# close temporary created file to be able to delete it later
25+
os.close(fd)
26+
2427
board = pcbnew.GetBoard()
2528
title_block = board.GetTitleBlock()
2629
self.report(10)
@@ -126,19 +129,35 @@ def run(self):
126129
json.dump(components, outfile)
127130

128131
# # Create ZIP file
129-
temp_file = shutil.make_archive(temp_file, 'zip', temp_dir)
132+
zip_file = shutil.make_archive(temp_file, 'zip', temp_dir)
130133
props = board.GetProperties()
131-
if props.has_key('aisler_export_locally'):
132-
path = os.path.dirname(os.path.abspath(board.GetFileName()))
134+
if props.has_key('aisler_local_export_path'):
135+
if props['aisler_local_export_path'] is not '':
136+
path = os.path.dirname(os.path.abspath(board.GetFileName())) + '/' + props['aisler_local_export_path']
137+
path = os.path.normpath(path)
138+
if not os.path.isdir(path):
139+
os.makedirs(path)
140+
else:
141+
path = os.path.dirname(os.path.abspath(board.GetFileName()))
142+
filename = "aisler_export_" + os.path.splitext(os.path.basename(board.GetFileName()))[0] + '.zip'
143+
shutil.copy(zip_file, os.path.join(path, filename))
144+
self.report(-1)
145+
elif props.has_key('aisler_export_locally'):
146+
path = os.path.dirname(os.path.abspath(board.GetFileName()))
133147
filename = "aisler_export_" + os.path.splitext(os.path.basename(board.GetFileName()))[0] + '.zip'
134-
shutil.copy(temp_file, os.path.join(path, filename))
148+
shutil.copy(zip_file, os.path.join(path, filename))
135149
self.report(-1)
136150
else:
137-
self.push_to_webservice(temp_file, project_id, board)
151+
self.push_to_webservice(zip_file, project_id, board)
152+
153+
# delete temporary data
154+
os.remove(zip_file)
155+
os.remove(temp_file)
156+
shutil.rmtree(temp_dir, ignore_errors = True)
138157

139-
def push_to_webservice(self, temp_file, project_id, board):
158+
def push_to_webservice(self, zip_file, project_id, board):
140159
title_block = board.GetTitleBlock()
141-
files = {'upload[file]': open(temp_file, 'rb')}
160+
files = {'upload[file]': open(zip_file, 'rb')}
142161

143162
self.report(40)
144163
if project_id:

0 commit comments

Comments
 (0)