Move "get_project_id" to the project helpers

This commit is contained in:
Ivan Kravets
2023-07-21 15:28:26 +03:00
parent 9deb7f4275
commit 5f75e36efd
3 changed files with 9 additions and 5 deletions

View File

@ -258,10 +258,6 @@ def get_cid():
return cid
def get_project_id(project_dir):
return hashlib.sha1(hashlib_encode_data(project_dir)).hexdigest()
def get_user_agent():
data = [
"PlatformIO/%s" % __version__,

View File

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import hashlib
import os
import re
import subprocess
@ -28,6 +29,12 @@ def get_project_dir():
return os.getcwd()
def get_project_id(project_dir=None):
return hashlib.sha1(
hashlib_encode_data(project_dir or get_project_dir())
).hexdigest()
def is_platformio_project(project_dir=None):
if not project_dir:
project_dir = get_project_dir()

View File

@ -29,6 +29,7 @@ from platformio.cli import PlatformioCLI
from platformio.debug.config.base import DebugConfigBase
from platformio.http import HTTPSession, ensure_internet_on
from platformio.proc import is_ci
from platformio.project.helpers import get_project_id
KEEP_MAX_REPORTS = 100
SEND_MAX_EVENTS = 25
@ -218,7 +219,7 @@ def dump_project_env_params(config, env, platform):
for option in non_sensitive_data
if config.has_option(section, option)
}
params["pid"] = app.get_project_id(os.path.dirname(config.path))
params["pid"] = get_project_id(os.path.dirname(config.path))
params["platform_name"] = platform.name
params["platform_version"] = platform.version
return params