File tree Expand file tree Collapse file tree 4 files changed +46
-9
lines changed
Expand file tree Collapse file tree 4 files changed +46
-9
lines changed Original file line number Diff line number Diff line change 11* .yml
2+ ** /__pycache__
Original file line number Diff line number Diff line change @@ -39,8 +39,8 @@ RUN cd /actions-runner && \
3939# Fix for Fedora not finding libstlink.so.1
4040
4141RUN pip install PyYAML
42- COPY register-runner .py /actions-runner
43- RUN chmod +x /actions-runner/register-runner .py
42+ COPY register_runner .py /actions-runner
43+ RUN chmod +x /actions-runner/register_runner .py
4444
4545ENV PATH="/actions-runner:${PATH}"
4646
@@ -49,4 +49,4 @@ ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64
4949
5050WORKDIR /actions-runner
5151
52- ENTRYPOINT [ "/actions-runner/register-runner .py" ]
52+ ENTRYPOINT [ "/actions-runner/register_runner .py" ]
Original file line number Diff line number Diff line change 1+ #!/bin/python3
2+ import os
3+ import sys
4+
5+ sys .path .insert (0 , os .path .dirname (os .path .abspath (__file__ )))
6+ import register_runner
7+
8+ if __name__ == "__main__" :
9+ chips = register_runner .get_chips ()
10+ if len (sys .argv ) != 3 :
11+ print ("Usage: %s <device>" % sys .argv [0 ])
12+ print ("Available devices:" )
13+ for chip in chips :
14+ print (" %s" % chip )
15+ sys .exit (1 )
16+
17+ devices = list (filter (lambda x : x ["dev_type" ] == sys .argv [1 ], chips ))
18+
19+ if len (devices ) == 0 :
20+ print ("Device not found" )
21+ sys .exit (1 )
22+
23+ device = devices [0 ]
24+
25+ print (device ['serial' ])
26+
Original file line number Diff line number Diff line change 1- #!/bin/python
1+ #!/bin/python3
22import os
33import re
44import subprocess
@@ -115,7 +115,14 @@ class Config(TypedDict):
115115 serial_map : Dict [str , str ]
116116 runner_name : str
117117
118- def parse_config_file (config_file : str ) -> dict :
118+ def parse_config_file (config_file : str = None ) -> dict :
119+ if config_file is None :
120+ env_value = os .getenv ("CHIPS_FILE_PATH" )
121+ if env_value :
122+ config_file = env_value
123+ else :
124+ config_file = os .path .join (os .path .dirname (os .path .abspath (__file__ )), "chips.yml" )
125+
119126 with open (config_file ) as f :
120127 return yaml .safe_load (f )
121128
@@ -138,10 +145,8 @@ def parse_config_file(config_file: str) -> dict:
138145
139146 return config
140147
141- def main ():
142- config_file_path = os .getenv ("CHIPS_FILE_PATH" ) or "chips.yml"
143-
144- config = parse_config_file (config_file_path )
148+ def get_chips ():
149+ config = parse_config_file ()
145150 probe_info = run_command ("st-info --probe" )
146151 if not probe_info :
147152 print ("No output from st-info --probe" )
@@ -156,6 +161,11 @@ def main():
156161 if probe ["serial" ] in config ["serial_map" ]:
157162 chips [i ]["dev_type" ] = config ["serial_map" ][probe ["serial" ]]
158163
164+ return chips
165+
166+ def main ():
167+ chips = get_chips ()
168+
159169 print (yaml .dump (chips ))
160170
161171 labels = set ()
You can’t perform that action at this time.
0 commit comments