Просмотр исходного кода

Merge branch 'master' into master

Koub 5 лет назад
Родитель
Сommit
2fcc5d8fd2

+ 32 - 16
.github/ISSUE_TEMPLATE.md

@@ -1,33 +1,49 @@
+---
+name: Bug report
+about: Create a report to help us fix issues.
+title: ''
+labels: 'Type: Bug'
+assignees: ''
+
+---
+
 <!--
-The following template is useful for filing new issues. Processing an issue will go much faster when this is filled out, and issues which do not use this template WILL BE REMOVED.
+Processing an issue will go much faster when this is filled out, and issues which do not use this template WILL BE REMOVED and no fix will be considered!
 
 Before filing, PLEASE check if the issue already exists (either open or closed) by using the search bar on the issues page. If it does, comment there. Even if it's closed, we can reopen it based on your comment.
 
-Also, please note the application version in the title of the issue. For example: "[3.2.1] Cannot connect to 3rd-party printer". Please do not write things like "Request:" or "[BUG]" in the title; this is what labels are for.
-
-It is also helpful to attach a project (.3mf or .curaproject) file and Cura log file so we can debug issues quicker.
-Information about how to find the log file can be found at https://github.com/Ultimaker/Cura/wiki/Cura-Preferences-and-Settings-Locations. To upload a project, try changing the extension to e.g. .curaproject.3mf.zip so that github accepts uploading the file. Otherwise we recommend http://wetransfer.com, but other file hosts like Google Drive or Dropbox work well too.
+Also, please note the application version in the title of the issue. For example: "[3.2.1] Cannot connect to 3rd-party printer". Please do NOT write things like "Request:" or "[BUG]" in the title; this is what labels are for.
 
 Thank you for using Cura!
 -->
 
-**Application Version**
-<!-- The version of the application this issue occurs with -->
+**Application version**
+(The version of the application this issue occurs with.)
 
 **Platform**
-<!-- Information about the operating system the issue occurs on -->
+(Information about the operating system the issue occurs on. Include at least the operating system and maybe GPU.)
 
 **Printer**
-<!-- Which printer was selected in Cura. Please attach project file as .curaproject.3mf.zip -->
+(Which printer was selected in Cura?)
 
-**Steps to Reproduce**
-<!-- Add the steps needed that lead up to the issue -->
+**Reproduction steps**
+1. (Something you did.)
+2. (Something you did next.)
 
-**Actual Results**
-<!-- What happens after the above steps have been followed -->
+**Screenshot(s)**
+(Image showing the problem, perhaps before/after images.) 
+
+**Actual results**
+(What happens after the above steps have been followed.)
 
 **Expected results**
-<!-- What should happen after the above steps have been followed -->
+(What should happen after the above steps have been followed.)
+
+**Project file**
+(For slicing bugs, provide a project which clearly shows the bug, by going to File->Save. For big files you may need to use WeTransfer or similar file sharing sites.)
+
+**Log file**
+(See https://github.com/Ultimaker/Cura#logging-issues to find the log file to upload, or copy a relevant snippet from it.)
 
-**Additional Information**
-<!-- Extra information relevant to the issue, like screenshots -->
+**Additional information**
+(Extra information relevant to the issue.)

+ 24 - 15
.github/ISSUE_TEMPLATE/bug-report.md

@@ -8,33 +8,42 @@ assignees: ''
 ---
 
 <!--
-The following template is useful for filing new issues. Processing an issue will go much faster when this is filled out, and issues which do not use this template WILL BE REMOVED.
+Processing an issue will go much faster when this is filled out, and issues which do not use this template WILL BE REMOVED and no fix will be considered!
 
 Before filing, PLEASE check if the issue already exists (either open or closed) by using the search bar on the issues page. If it does, comment there. Even if it's closed, we can reopen it based on your comment.
 
-Also, please note the application version in the title of the issue. For example: "[3.2.1] Cannot connect to 3rd-party printer". Please do not write things like "Request:" or "[BUG]" in the title; this is what labels are for.
-
-It is also helpful to attach a project (.3mf or .curaproject) file and Cura log file so we can debug issues quicker. Information about how to find the log file can be found at https://github.com/Ultimaker/Cura#logging-issues 
-
-To upload a project, try changing the extension to e.g. .curaproject.3mf.zip so that GitHub accepts uploading the file. Otherwise, we recommend http://wetransfer.com, but other file hosts like Google Drive or Dropbox work well too.
+Also, please note the application version in the title of the issue. For example: "[3.2.1] Cannot connect to 3rd-party printer". Please do NOT write things like "Request:" or "[BUG]" in the title; this is what labels are for.
 
 Thank you for using Cura!
 -->
 
-**Application Version**
-<!-- The version of the application this issue occurs with -->
+**Application version**
+(The version of the application this issue occurs with.)
 
 **Platform**
-<!-- Information about the operating system the issue occurs on. Include at least the operating system. In the case of visual glitches/issues, also include information about your graphics drivers and GPU. -->
+(Information about the operating system the issue occurs on. Include at least the operating system and maybe GPU.)
 
 **Printer**
-<!-- Which printer was selected in Cura? If possible, please attach project file as .curaproject.3mf.zip -->
+(Which printer was selected in Cura?)
+
+**Reproduction steps**
+1. (Something you did.)
+2. (Something you did next.)
 
-**Actual Results**
-<!-- What happens after the above steps have been followed -->
+**Screenshot(s)**
+(Image showing the problem, perhaps before/after images.) 
+
+**Actual results**
+(What happens after the above steps have been followed.)
 
 **Expected results**
-<!-- What should happen after the above steps have been followed -->
+(What should happen after the above steps have been followed.)
+
+**Project file**
+(For slicing bugs, provide a project which clearly shows the bug, by going to File->Save. For big files you may need to use WeTransfer or similar file sharing sites.)
+
+**Log file**
+(See https://github.com/Ultimaker/Cura#logging-issues to find the log file to upload, or copy a relevant snippet from it.)
 
-**Additional Information**
-<!-- Extra information relevant to the issue, like screenshots -->
+**Additional information**
+(Extra information relevant to the issue.)

+ 6 - 5
.github/ISSUE_TEMPLATE/feature_request.md

@@ -8,15 +8,16 @@ assignees: ''
 ---
 
 **Is your feature request related to a problem? Please describe.**
-<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
+(A clear and concise description of what the problem is. Ex. I'm always frustrated when [...])
 
 **Describe the solution you'd like**
-<!--A clear and concise description of what you want to happen. If possible, describe why you think this is a good solution.-->
+(A clear and concise description of what you want to happen. If possible, describe why you think this is a good solution.)
 
 **Describe alternatives you've considered**
-<!-- A clear and concise description of any alternative solutions or features you've considered. Again, if possible, think about why these alternatives are not working out. -->
+(A clear and concise description of any alternative solutions or features you've considered. Again, if possible, think about why these alternatives are not working out.)
 
 **Affected users and/or printers**
-<!-- Who do you think will benefit from this? Is everyone going to benefit from these changes? Only a few people? --> 
+(Who do you think will benefit from this? Is everyone going to benefit from these changes? Or specific kinds of users?)
+
 **Additional context**
-<!-- Add any other context or screenshots about the feature request here. -->
+(Add any other context or screenshots about the feature request here.)

+ 13 - 0
.github/workflows/cicd.yml

@@ -0,0 +1,13 @@
+---
+name: CI/CD
+on: [push, pull_request]
+jobs:
+  build:
+    name: Build and test
+    runs-on: ubuntu-latest
+    container: ultimaker/cura-build-environment
+    steps:
+    - name: Checkout Cura
+      uses: actions/checkout@v2
+    - name: Build and test
+      run: docker/build.sh

+ 5 - 1
.gitignore

@@ -35,7 +35,7 @@ cura.desktop
 .pydevproject
 .settings
 
-#Externally located plug-ins.
+#Externally located plug-ins commonly installed by our devs.
 plugins/cura-big-flame-graph
 plugins/cura-god-mode-plugin
 plugins/cura-siemensnx-plugin
@@ -52,6 +52,7 @@ plugins/FlatProfileExporter
 plugins/GodMode
 plugins/OctoPrintPlugin
 plugins/ProfileFlattener
+plugins/SettingsGuide
 plugins/X3GWriter
 
 #Build stuff
@@ -72,3 +73,6 @@ run.sh
 CuraEngine
 
 /.coverage
+
+#Prevents import failures when plugin running tests
+plugins/__init__.py

+ 0 - 12
.gitlab-ci.yml

@@ -1,12 +0,0 @@
-image: registry.gitlab.com/ultimaker/cura/cura-build-environment:centos7
-
-stages:
-  - build
-
-build-and-test:
-  stage: build
-  script:
-    - docker/build.sh
-  artifacts:
-    paths:
-      - build

+ 5 - 4
CMakeLists.txt

@@ -20,11 +20,12 @@ set(CURA_APP_NAME "cura" CACHE STRING "Short name of Cura, used for configuratio
 set(CURA_APP_DISPLAY_NAME "Ultimaker Cura" CACHE STRING "Display name of Cura")
 set(CURA_VERSION "master" CACHE STRING "Version name of Cura")
 set(CURA_BUILDTYPE "" CACHE STRING "Build type of Cura, eg. 'PPA'")
-set(CURA_SDK_VERSION "" CACHE STRING "SDK version of Cura")
 set(CURA_CLOUD_API_ROOT "" CACHE STRING "Alternative Cura cloud API root")
 set(CURA_CLOUD_API_VERSION "" CACHE STRING "Alternative Cura cloud API version")
+set(CURA_CLOUD_ACCOUNT_API_ROOT "" CACHE STRING "Alternative Cura cloud account API version")
 
 configure_file(${CMAKE_SOURCE_DIR}/cura.desktop.in ${CMAKE_BINARY_DIR}/cura.desktop @ONLY)
+
 configure_file(cura/CuraVersion.py.in CuraVersion.py @ONLY)
 
 
@@ -48,7 +49,7 @@ endif()
 
 
 if(NOT ${URANIUM_DIR} STREQUAL "")
-    set(CMAKE_MODULE_PATH "${URANIUM_DIR}/cmake")
+    set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${URANIUM_DIR}/cmake")
 endif()
 if(NOT ${URANIUM_SCRIPTS_DIR} STREQUAL "")
     list(APPEND CMAKE_MODULE_PATH ${URANIUM_DIR}/cmake)
@@ -62,8 +63,8 @@ endif()
 
 install(DIRECTORY resources
         DESTINATION ${CMAKE_INSTALL_DATADIR}/cura)
-install(DIRECTORY plugins
-        DESTINATION lib${LIB_SUFFIX}/cura)
+
+include(CuraPluginInstall)
 
 if(NOT APPLE AND NOT WIN32)
     install(FILES cura_app.py

+ 99 - 0
cmake/CuraPluginInstall.cmake

@@ -0,0 +1,99 @@
+# Copyright (c) 2019 Ultimaker B.V.
+# CuraPluginInstall.cmake is released under the terms of the LGPLv3 or higher.
+
+#
+# This module detects all plugins that need to be installed and adds them using the CMake install() command.
+# It detects all plugin folder in the path "plugins/*" where there's a "plugin.json" in it.
+#
+# Plugins can be configured to NOT BE INSTALLED via the variable "CURA_NO_INSTALL_PLUGINS" as a list of string in the
+# form of "a;b;c" or "a,b,c". By default all plugins will be installed.
+#
+
+# FIXME: Remove the code for CMake <3.12 once we have switched over completely.
+# FindPython3 is a new module since CMake 3.12. It deprecates FindPythonInterp and FindPythonLibs. The FindPython3
+# module is copied from the CMake repository here so in CMake <3.12 we can still use it.
+if(${CMAKE_VERSION} VERSION_LESS 3.12)
+    # Use FindPythonInterp and FindPythonLibs for CMake <3.12
+    find_package(PythonInterp 3 REQUIRED)
+
+    set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE})
+else()
+    # Use FindPython3 for CMake >=3.12
+    find_package(Python3 REQUIRED COMPONENTS Interpreter)
+endif()
+
+# Options or configuration variables
+set(CURA_NO_INSTALL_PLUGINS "" CACHE STRING "A list of plugins that should not be installed, separated with ';' or ','.")
+
+file(GLOB_RECURSE _plugin_json_list ${CMAKE_SOURCE_DIR}/plugins/*/plugin.json)
+list(LENGTH _plugin_json_list _plugin_json_list_len)
+
+# Sort the lists alphabetically so we can handle cases like this:
+#   - plugins/my_plugin/plugin.json
+#   - plugins/my_plugin/my_module/plugin.json
+# In this case, only "plugins/my_plugin" should be added via install().
+set(_no_install_plugin_list ${CURA_NO_INSTALL_PLUGINS})
+# Sanitize the string so the comparison will be case-insensitive.
+string(STRIP   "${_no_install_plugin_list}" _no_install_plugin_list)
+string(TOLOWER "${_no_install_plugin_list}" _no_install_plugin_list)
+
+# WORKAROUND counterpart of what's in cura-build.
+string(REPLACE "," ";" _no_install_plugin_list "${_no_install_plugin_list}")
+
+list(LENGTH _no_install_plugin_list _no_install_plugin_list_len)
+
+if(_no_install_plugin_list_len GREATER 0)
+    list(SORT _no_install_plugin_list)
+endif()
+if(_plugin_json_list_len GREATER 0)
+    list(SORT _plugin_json_list)
+endif()
+
+# Check all plugin directories and add them via install() if needed.
+set(_install_plugin_list "")
+foreach(_plugin_json_path ${_plugin_json_list})
+    get_filename_component(_plugin_dir ${_plugin_json_path} DIRECTORY)
+    file(RELATIVE_PATH _rel_plugin_dir ${CMAKE_CURRENT_SOURCE_DIR} ${_plugin_dir})
+    get_filename_component(_plugin_dir_name ${_plugin_dir} NAME)
+
+    # Make plugin name comparison case-insensitive
+    string(TOLOWER "${_plugin_dir_name}" _plugin_dir_name_lowercase)
+
+    # Check if this plugin needs to be skipped for installation
+    set(_add_plugin ON)  # Indicates if this plugin should be added to the build or not.
+    set(_is_no_install_plugin OFF)  # If this plugin will not be added, this indicates if it's because the plugin is
+                                    # specified in the NO_INSTALL_PLUGINS list.
+    if(_no_install_plugin_list)
+        if("${_plugin_dir_name_lowercase}" IN_LIST _no_install_plugin_list)
+            set(_add_plugin OFF)
+            set(_is_no_install_plugin ON)
+        endif()
+    endif()
+
+    # Make sure this is not a subdirectory in a plugin that's already in the install list
+    if(_add_plugin)
+        foreach(_known_install_plugin_dir ${_install_plugin_list})
+            if(_plugin_dir MATCHES "${_known_install_plugin_dir}.+")
+                set(_add_plugin OFF)
+                break()
+            endif()
+        endforeach()
+    endif()
+
+    if(_add_plugin)
+        message(STATUS "[+] PLUGIN TO INSTALL: ${_rel_plugin_dir}")
+        get_filename_component(_rel_plugin_parent_dir ${_rel_plugin_dir} DIRECTORY)
+        install(DIRECTORY ${_rel_plugin_dir}
+                DESTINATION lib${LIB_SUFFIX}/cura/${_rel_plugin_parent_dir}
+                PATTERN "__pycache__" EXCLUDE
+                PATTERN "*.qmlc" EXCLUDE
+                )
+        list(APPEND _install_plugin_list ${_plugin_dir})
+    elseif(_is_no_install_plugin)
+        message(STATUS "[-] PLUGIN TO REMOVE : ${_rel_plugin_dir}")
+        execute_process(COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/mod_bundled_packages_json.py
+                        -d ${CMAKE_CURRENT_SOURCE_DIR}/resources/bundled_packages
+                        ${_plugin_dir_name}
+                        RESULT_VARIABLE _mod_json_result)
+    endif()
+endforeach()

+ 1 - 1
cmake/CuraTests.cmake

@@ -47,7 +47,7 @@ function(cura_add_test)
     if (NOT ${test_exists})
         add_test(
             NAME ${_NAME}
-            COMMAND ${Python3_EXECUTABLE} -m pytest --verbose --full-trace --capture=no --no-print-log --junitxml=${CMAKE_BINARY_DIR}/junit-${_NAME}.xml ${_DIRECTORY}
+            COMMAND ${Python3_EXECUTABLE} -m pytest --junitxml=${CMAKE_BINARY_DIR}/junit-${_NAME}.xml ${_DIRECTORY}
         )
         set_tests_properties(${_NAME} PROPERTIES ENVIRONMENT LANG=C)
         set_tests_properties(${_NAME} PROPERTIES ENVIRONMENT "PYTHONPATH=${_PYTHONPATH}")

+ 69 - 0
cmake/mod_bundled_packages_json.py

@@ -0,0 +1,69 @@
+#!/usr/bin/env python3
+#
+# This script removes the given package entries in the bundled_packages JSON files. This is used by the PluginInstall
+# CMake module.
+#
+
+import argparse
+import collections
+import json
+import os
+import sys
+
+
+## Finds all JSON files in the given directory recursively and returns a list of those files in absolute paths.
+#
+#  \param work_dir The directory to look for JSON files recursively.
+#  \return A list of JSON files in absolute paths that are found in the given directory.
+def find_json_files(work_dir: str) -> list:
+    json_file_list = []
+    for root, dir_names, file_names in os.walk(work_dir):
+        for file_name in file_names:
+            abs_path = os.path.abspath(os.path.join(root, file_name))
+            json_file_list.append(abs_path)
+    return json_file_list
+
+
+## Removes the given entries from the given JSON file. The file will modified in-place.
+#
+#  \param file_path The JSON file to modify.
+#  \param entries A list of strings as entries to remove.
+#  \return None
+def remove_entries_from_json_file(file_path: str, entries: list) -> None:
+    try:
+        with open(file_path, "r", encoding = "utf-8") as f:
+            package_dict = json.load(f, object_hook = collections.OrderedDict)
+    except Exception as e:
+        msg = "Failed to load '{file_path}' as a JSON file. This file will be ignored Exception: {e}"\
+            .format(file_path = file_path, e = e)
+        sys.stderr.write(msg + os.linesep)
+        return
+
+    for entry in entries:
+        if entry in package_dict:
+            del package_dict[entry]
+            print("[INFO] Remove entry [{entry}] from [{file_path}]".format(file_path = file_path, entry = entry))
+
+    try:
+        with open(file_path, "w", encoding = "utf-8", newline = "\n") as f:
+            json.dump(package_dict, f, indent = 4)
+    except Exception as e:
+        msg = "Failed to write '{file_path}' as a JSON file. Exception: {e}".format(file_path = file_path, e = e)
+        raise IOError(msg)
+
+
+def main() -> None:
+    parser = argparse.ArgumentParser("mod_bundled_packages_json")
+    parser.add_argument("-d", "--dir", dest = "work_dir",
+                        help = "The directory to look for bundled packages JSON files, recursively.")
+    parser.add_argument("entries", metavar = "ENTRIES", type = str, nargs = "+")
+
+    args = parser.parse_args()
+
+    json_file_list = find_json_files(args.work_dir)
+    for json_file_path in json_file_list:
+        remove_entries_from_json_file(json_file_path, args.entries)
+
+
+if __name__ == "__main__":
+    main()

Некоторые файлы не были показаны из-за большого количества измененных файлов