def execute(self, context): if not self.preset_name: msg = "Preset name is not specified" error(msg) self.report({'ERROR'}, msg) return {'CANCELLED'} path = get_preset_path(self.preset_name) gist_filename = self.preset_name + ".json" gist_description = self.preset_name with open(path, 'rb') as jsonfile: gist_body = jsonfile.read().decode('utf8') try: gist_url = sv_gist_tools.main_upload_function(gist_filename, gist_description, gist_body, show_browser=False) context.window_manager.clipboard = gist_url # full destination url info(gist_url) self.report({'WARNING'}, "Copied gist URL to clipboad") sv_gist_tools.write_or_append_datafiles(gist_url, gist_filename) except Exception as err: exception(err) self.report({'ERROR'}, "Error 222: net connection or github login failed!") return {'CANCELLED'} finally: return {'FINISHED'}
def execute(self, context): ng = context.space_data.node_tree gist_filename = ng.name gist_description = 'to do later?' layout_dict = create_dict_of_tree(ng, skip_set={}, selected=False) try: gist_body = json.dumps(layout_dict, sort_keys=True, indent=2) except Exception as err: if 'not JSON serializable' in repr(err): print(layout_dict) else: print(repr(err)) self.report({'WARNING'}, "See terminal/Command prompt for printout of error") return {'CANCELLED'} try: gist_url = sv_gist_tools.main_upload_function(gist_filename, gist_description, gist_body, show_browser=False) context.window_manager.clipboard = gist_url # full destination url print(gist_url) self.report({'WARNING'}, "Copied gistURL to clipboad") sv_gist_tools.write_or_append_datafiles(gist_url, gist_filename) except: self.report({'ERROR'}, "Error uploading the gist, check your internet connection!") finally: return {'FINISHED'}
def execute(self, context): ng = context.space_data.node_tree gist_filename = ng.name gist_description = 'to do later?' layout_dict = create_dict_of_tree(ng, skip_set={}, selected=False) try: gist_body = json.dumps(layout_dict, sort_keys=True, indent=2) except Exception as err: if 'not JSON serializable' in repr(err): print(layout_dict) else: print(repr(err)) self.report({'WARNING'}, "See terminal/Command prompt for printout of error") return {'CANCELLED'} try: gist_url = sv_gist_tools.main_upload_function(gist_filename, gist_description, gist_body, show_browser=False) context.window_manager.clipboard = gist_url # full destination url print(gist_url) self.report({'WARNING'}, "Copied gistURL to clipboad") sv_gist_tools.write_or_append_datafiles(gist_url, gist_filename) except: self.report( {'ERROR'}, "Error uploading the gist, check your internet connection!") finally: return {'FINISHED'}
def execute(self, context): ng = context.space_data.node_tree is_tree_exportable, msg = self.can_be_exported(ng) if not is_tree_exportable: self.report({'ERROR'}, msg) return {'CANCELLED'} gist_filename = ng.name app_version = bpy.app.version_string.replace(" ", "") time_stamp = strftime("%Y.%m.%d | %H:%M", localtime()) license = 'license: CC BY-SA' gist_description = f"Sverchok.{version_and_sha} | Blender.{app_version} | {ng.name} | {time_stamp} | {license}" # layout_dict = create_dict_of_tree(ng, skip_set={}, selected=self.selected_only) if self.selected_only: layout_dict = JSONExporter.get_nodes_structure( [node for node in ng.nodes if node.select]) else: layout_dict = JSONExporter.get_tree_structure(ng) try: gist_body = json.dumps(layout_dict, sort_keys=True, indent=2) except Exception as err: if 'not JSON serializable' in repr(err): error(layout_dict) exception(err) self.report({'WARNING'}, "See terminal/Command prompt for printout of error") return {'CANCELLED'} try: gist_url = sv_gist_tools.main_upload_function(gist_filename, gist_description, gist_body, show_browser=False) if not gist_url: self.report( {'ERROR'}, "You have not specified GitHub API access token, which is " + "required to create gists from Sverchok. Please see " + TOKEN_HELP_URL + " for more information.") return {'CANCELLED'} context.window_manager.clipboard = gist_url # full destination url info(gist_url) self.report({'WARNING'}, "Copied gist URL to clipboad") sv_gist_tools.write_or_append_datafiles(gist_url, gist_filename) return {'FINISHED'} except Exception as err: exception(err) self.report({'ERROR'}, "Error 222: net connection or github login failed!") return {'CANCELLED'}
def execute(self, context): ng = context.space_data.node_tree gist_filename = ng.name gist_description = "Sverchok_" + version_and_sha + ng.name + "_Bl_" + bpy.app.version_string.replace( " ", "") + str(tl().tm_year) + str(tl().tm_mon) + str( tl().tm_mday) + str(tl().tm_hour) layout_dict = create_dict_of_tree(ng, skip_set={}, selected=self.selected_only) try: gist_body = json.dumps(layout_dict, sort_keys=True, indent=2) except Exception as err: if 'not JSON serializable' in repr(err): error(layout_dict) exception(err) self.report({'WARNING'}, "See terminal/Command prompt for printout of error") return {'CANCELLED'} try: gist_url = sv_gist_tools.main_upload_function(gist_filename, gist_description, gist_body, show_browser=False) if not gist_url: self.report( {'ERROR'}, "You have not specified GitHub API access token, which is " + "required to create gists from Sverchok. Please see " + TOKEN_HELP_URL + " for more information.") return {'CANCELLED'} context.window_manager.clipboard = gist_url # full destination url info(gist_url) self.report({'WARNING'}, "Copied gist URL to clipboad") sv_gist_tools.write_or_append_datafiles(gist_url, gist_filename) return {'FINISHED'} except Exception as err: exception(err) self.report({'ERROR'}, "Error 222: net connection or github login failed!") return {'CANCELLED'}