Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _rename_unpacked_dir(self):
if self.uncompressed_name:
unpack_dir = util.safe_join(
self.packages_dir, self.uncompressed_name)
package_dir = util.safe_join(
self.packages_dir, self.package_name)
if isdir(unpack_dir):
rename(unpack_dir, package_dir)
def _get_headers():
enc = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdWJsaWNfdG9rZW4iOiJ0' + \
'b2tlbiBhNTk2OTUwNjFhYzRkMjBkZjEwNTFlZDljOWZjNGI4M2Q0NzAyYzA3I' + \
'n0.POR6Iae_pSt0m6h-AaRi1X6QaRcnnfl9aZbTSV0BUJw'
return {'Authorization': util.decode(enc).get('public_token')}
def _check_serial(self, board, board_data, ext_serial_port):
if 'usb' not in board_data:
raise Exception('Missing board configuration: usb')
usb_data = board_data.get('usb')
hwid = '{0}:{1}'.format(
usb_data.get('vid'),
usb_data.get('pid')
)
# Match the discovered serial ports
serial_ports = util.get_serial_ports()
if len(serial_ports) == 0:
# Board not available
raise Exception('board ' + board + ' not available')
for serial_port_data in serial_ports:
port = serial_port_data.get('port')
if ext_serial_port and ext_serial_port != port:
# If the --device options is set but it doesn't match
# the detected port, skip the port.
continue
if hwid.lower() in serial_port_data.get('hwid').lower():
if 'tinyprog' in board_data and \
not self._check_tinyprog(board_data, port):
# If the board uses tinyprog use its port detection
# to double check the detected port.
# If the port is not detected, skip the port.
continue
def _preserve_filemtime(self, lmdate):
if lmdate is not None:
timedata = parsedate_tz(lmdate)
lmtime = mktime(timedata[:9])
util.change_filemtime(self._destination, lmtime)