Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update python scripts #27157

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Marlin/src/HAL/STM32F1/build_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

# extra script for linker options
else:
import pioutil
from .....buildroot.share.PlatformIO.scripts import pioutil
if pioutil.is_pio_build():
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Expand Down
3 changes: 2 additions & 1 deletion buildroot/share/PlatformIO/scripts/SAMD21_minitronics20.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
if pioutil.is_pio_build():
from os.path import join, isfile
import shutil

from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved

mf = env["MARLIN_FEATURES"]
Expand Down
3 changes: 2 additions & 1 deletion buildroot/share/PlatformIO/scripts/SAMD51_grandcentral_m4.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
if pioutil.is_pio_build():
from os.path import join, isfile
import shutil

from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

mf = env["MARLIN_FEATURES"]
Expand Down
4 changes: 3 additions & 1 deletion buildroot/share/PlatformIO/scripts/STM32F103RC_MEEB_3DP.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#
import pioutil
if pioutil.is_pio_build():

from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
projenv = DefaultEnvironment()
Import("env", "projenv")

flash_size = 0
Expand Down
5 changes: 3 additions & 2 deletions buildroot/share/PlatformIO/scripts/STM32F103RC_fysetc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#
import pioutil
if pioutil.is_pio_build():
from os.path import join
from os.path import expandvars
from os.path import join, expandvars
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

# Custom HEX from ELF
Expand Down
5 changes: 3 additions & 2 deletions buildroot/share/PlatformIO/scripts/STM32F1_create_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
#
import pioutil
if pioutil.is_pio_build():
import shutil,marlin
import shutil, marlin
from pathlib import Path

from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")
platform = env.PioPlatform()
board = env.BoardConfig()
Expand Down
2 changes: 2 additions & 0 deletions buildroot/share/PlatformIO/scripts/add_nanolib.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#
# add_nanolib.py
#
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

env.Append(LINKFLAGS=["--specs=nano.specs"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have been removed as part of #20354.

2 changes: 1 addition & 1 deletion buildroot/share/PlatformIO/scripts/chitu_crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
import pioutil
if pioutil.is_pio_build():
import struct,uuid,marlin
import struct, uuid, marlin

board = marlin.env.BoardConfig()

Expand Down
6 changes: 4 additions & 2 deletions buildroot/share/PlatformIO/scripts/collect-code-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
if pioutil.is_pio_build():

import os, re
Import("env")
Import("projenv")
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
projenv = DefaultEnvironment()
Import("env", "projenv")

os.environ['PATH'] = f"./buildroot/bin/:./buildroot/tests/:{os.environ['PATH']}"

Expand Down
2 changes: 2 additions & 0 deletions buildroot/share/PlatformIO/scripts/common-cxxflags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import pioutil
if pioutil.is_pio_build():
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

cxxflags = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#
import pioutil
if pioutil.is_pio_build():
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
projenv = DefaultEnvironment()
Import("env", "projenv")

def apply_board_build_flags():
Expand Down
4 changes: 3 additions & 1 deletion buildroot/share/PlatformIO/scripts/common-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import pioutil
if pioutil.is_pio_build():

import subprocess,os,re,fnmatch,glob
import os, re, fnmatch, glob
srcfilepattern = re.compile(r".*[.](cpp|c)$")
marlinbasedir = os.path.join(os.getcwd(), "Marlin/")
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

from platformio.package.meta import PackageSpec
Expand Down
9 changes: 5 additions & 4 deletions buildroot/share/PlatformIO/scripts/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def blab(str,level=1):
if verbose >= level: print(f"[config] {str}")

def config_path(cpath):
return Path("Marlin", cpath, encoding='utf-8')
return Path("Marlin", cpath)

# Apply a single name = on/off ; name = value ; etc.
# TODO: Limit to the given (optional) configuration
Expand Down Expand Up @@ -223,7 +223,7 @@ def apply_config_ini(cp):
sect = 'base'
if '@' in ckey: sect, ckey = map(str.strip, ckey.split('@'))
cp2 = configparser.ConfigParser()
cp2.read(config_path(ckey))
cp2.read(config_path(ckey), encoding='utf-8')
apply_sections(cp2, sect)
ckey = 'base'

Expand Down Expand Up @@ -270,7 +270,7 @@ def apply_config_ini(cp):

if ini_file:
user_ini = configparser.ConfigParser()
user_ini.read(ini_file)
user_ini.read(ini_file, encoding='utf-8')
apply_config_ini(user_ini)

else:
Expand All @@ -279,7 +279,8 @@ def apply_config_ini(cp):
#
import pioutil
if pioutil.is_pio_build():

from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

try:
Expand Down
4 changes: 3 additions & 1 deletion buildroot/share/PlatformIO/scripts/download_mks_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
#
import pioutil
if pioutil.is_pio_build():
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")
import requests,zipfile,tempfile,shutil
import requests, zipfile, tempfile, shutil
from pathlib import Path

url = "https://github.com/makerbase-mks/Mks-Robin-Nano-Marlin2.0-Firmware/archive/0263cdaccf.zip"
Expand Down
3 changes: 2 additions & 1 deletion buildroot/share/PlatformIO/scripts/fix_framework_weakness.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import shutil
from os.path import join, isfile
from pprint import pprint

from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

if env.MarlinHas("POSTMORTEM_DEBUGGING"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pioutil, re
marlin_variant_pattern = re.compile("marlin_.*")
if pioutil.is_pio_build():
import shutil,marlin
import shutil, marlin
from pathlib import Path

#
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/PlatformIO/scripts/lerdge.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
import pioutil
if pioutil.is_pio_build():
import os,marlin
import os, marlin

board = marlin.env.BoardConfig()

Expand Down
4 changes: 1 addition & 3 deletions buildroot/share/PlatformIO/scripts/mc-apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
#
# Create a Configuration from marlin_config.json
#
import json
import sys
import shutil
import json, sys, shutil

opt_output = '--opt' in sys.argv
output_suffix = '.sh' if opt_output else '' if '--bare-output' in sys.argv else '.gen'
Expand Down
3 changes: 2 additions & 1 deletion buildroot/share/PlatformIO/scripts/openblt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import pioutil
if pioutil.is_pio_build():
from os.path import join

from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

board = env.BoardConfig()
Expand Down
4 changes: 3 additions & 1 deletion buildroot/share/PlatformIO/scripts/preflight-checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import pioutil
if pioutil.is_pio_build():

import re,sys
import re, sys
from pathlib import Path
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

def get_envs_for_board(board):
Expand Down
2 changes: 2 additions & 0 deletions buildroot/share/PlatformIO/scripts/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import pioutil
if pioutil.is_pio_build():
# Get the environment thus far for the build
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

#print(env.Dump())
Expand Down
2 changes: 2 additions & 0 deletions buildroot/share/PlatformIO/scripts/stm32_serialbuffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#
import pioutil
if pioutil.is_pio_build():
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

# Get a build flag's value or None
Expand Down
4 changes: 2 additions & 2 deletions buildroot/share/dwin/bin/DWIN_ICO.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ class Entry():
'''
__slots__ = ('width', 'height', 'offset', 'length', 'filename')

def __init__(self, w=0, h=0, length=0, offset=0):
def __init__(self, w=0, h=0, length=0, offset=0, filename=None):
self.width = w
self.height = h
self.offset = offset
self.length = length
self.filename = None
self.filename = filename

def parseRawData(self, rawEntryBytes):
if len(rawEntryBytes) != 16:
Expand Down
4 changes: 2 additions & 2 deletions buildroot/share/scripts/MarlinBinaryProtocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def send_ascii(self, data, send_and_forget = False):
except ReadTimeout:
self.errors += 1
#print("Packetloss detected..")
except serial.serialutil.SerialException:
except serial.SerialException:
return
self.packet_transit = None

Expand All @@ -201,7 +201,7 @@ def corrupt_array(self, data):

def transmit_packet(self, packet):
packet = bytearray(packet)
if(self.simulate_errors > 0 and random.random() > (1.0 - self.simulate_errors)):
if (self.simulate_errors > 0 and random.random() > (1.0 - self.simulate_errors)):
if random.random() > 0.9:
#random data drop
start = random.randint(0, len(packet))
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/scripts/createTemperatureLookupMarlin.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from __future__ import division

from math import *
import sys,getopt
import sys, getopt

"Constants"
ZERO = 273.15 # zero point of Kelvin scale
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/scripts/gen-tft-image.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# Generate Marlin TFT Images from bitmaps/PNG/JPG

import sys,struct
import sys, struct
from PIL import Image

def image2bin(image, output_file):
Expand Down
16 changes: 8 additions & 8 deletions buildroot/share/scripts/languageImport.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""

import sys, re, requests, csv, datetime
from languageUtil import namebyid
#from languageUtil import namebyid

LANGHOME = "Marlin/src/lcd/language"
OUTDIR = 'out-language'
Expand Down Expand Up @@ -76,10 +76,10 @@
# Add the named string for all the included languages
name = row[0]
for i in range(1, numcols):
str = row[i]
if str:
str_key = row[i]
if str_key:
col = columns[i]
strings_per_lang[col['lang']][col['style']][name] = str
strings_per_lang[col['lang']][col['style']][name] = str_key

# Create a folder for the imported language outfiles
from pathlib import Path
Expand Down Expand Up @@ -199,11 +199,11 @@
comm = ''
if lang != 'en' and 'en' in strings_per_lang:
en = strings_per_lang['en']
if name in en[style]: str = en[style][name]
elif name in en['Narrow']: str = en['Narrow'][name]
if str:
if name in en[style]: str_key = en[style][name]
elif name in en['Narrow']: str_key = en['Narrow'][name]
if str_key:
cfmt = '%%%ss// %%s' % (50 - len(val) if len(val) < 50 else 1)
comm = cfmt % (' ', str)
comm = cfmt % (' ', str_key)

# Write out the string definition
f.write(lstr_fmt % (name, val, comm))
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/scripts/languageUtil.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# marlang.py
# languageUtil.py
#

# A dictionary to contain language names
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/scripts/rle16_compress_cpp_image_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Usage: rle16_compress_cpp_image_data.py INPUT_FILE.cpp OUTPUT_FILE.cpp
#
import sys,struct
import sys, struct
import re

def addCompressedData(input_file, output_file):
Expand Down
2 changes: 1 addition & 1 deletion buildroot/share/scripts/rle_compress_bitmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
# Usage: rle_compress_bitmap.py INPUT_FILE OUTPUT_FILE
#
import sys,struct
import sys, struct
import re

def addCompressedData(input_file, output_file):
Expand Down
10 changes: 3 additions & 7 deletions buildroot/share/scripts/upload.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import argparse
import sys
import os
import time
import random
import serial

import argparse, sys, os, time, random, serial
from SCons.Script import DefaultEnvironment
env = DefaultEnvironment()
Import("env")

import MarlinBinaryProtocol
Expand Down
Loading