the PyUtility is not used, so we remove it.
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
+++ /dev/null
-## @file\r
-# Makefile\r
-#\r
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-\r
-!INCLUDE ..\Makefiles\ms.common\r
-\r
-APPNAME = GenSec\r
-\r
-LIBS = $(LIB_PATH)\Common.lib\r
-\r
-OBJECTS = PyUtility.obj\r
-\r
-#CFLAGS = $(CFLAGS) /nodefaultlib:libc.lib\r
-\r
-!INCLUDE ..\Makefiles\ms.app\r
-\r
+++ /dev/null
-/** @file\r
-Python Utility\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials are licensed and made available\r
-under the terms and conditions of the BSD License which accompanies this\r
-distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <Python.h>\r
-#include <Windows.h>\r
-#include <Common/UefiBaseTypes.h>\r
-\r
-/*\r
- SaveFileToDisk(FilePath, Content)\r
-*/\r
-STATIC\r
-PyObject*\r
-SaveFileToDisk (\r
- PyObject *Self,\r
- PyObject *Args\r
- )\r
-{\r
- CHAR8 *File;\r
- UINT8 *Data;\r
- UINTN DataLength;\r
- UINTN WriteBytes;\r
- UINTN Status;\r
- HANDLE FileHandle;\r
- PyObject *ReturnValue = Py_False;\r
-\r
- Status = PyArg_ParseTuple(\r
- Args,\r
- "ss#",\r
- &File,\r
- &Data,\r
- &DataLength\r
- );\r
- if (Status == 0) {\r
- return NULL;\r
- }\r
-\r
- FileHandle = CreateFile(\r
- File,\r
- GENERIC_WRITE,\r
- FILE_SHARE_WRITE|FILE_SHARE_READ|FILE_SHARE_DELETE,\r
- NULL,\r
- CREATE_ALWAYS,\r
- FILE_ATTRIBUTE_NORMAL,\r
- NULL\r
- );\r
- if (FileHandle == INVALID_HANDLE_VALUE) {\r
- PyErr_SetString(PyExc_Exception, "File creation failure");\r
- return NULL;\r
- }\r
-\r
- while (WriteFile(FileHandle, Data, DataLength, &WriteBytes, NULL)) {\r
- if (DataLength <= WriteBytes) {\r
- DataLength = 0;\r
- break;\r
- }\r
-\r
- Data += WriteBytes;\r
- DataLength -= WriteBytes;\r
- }\r
-\r
- if (DataLength != 0) {\r
- // file saved unsuccessfully\r
- PyErr_SetString(PyExc_Exception, "File write failure");\r
- goto Done;\r
- }\r
-\r
- //\r
- // Flush buffer may slow down the whole build performance (average 10s slower)\r
- //\r
- //if (!FlushFileBuffers(FileHandle)) {\r
- // PyErr_SetString(PyExc_Exception, "File flush failure");\r
- // goto Done;\r
- //}\r
-\r
- // success!\r
- ReturnValue = Py_True;\r
-\r
-Done:\r
- CloseHandle(FileHandle);\r
- return ReturnValue;\r
-}\r
-\r
-STATIC INT8 SaveFileToDiskDocs[] = "SaveFileToDisk(): Make sure the file is saved to disk\n";\r
-\r
-STATIC PyMethodDef PyUtility_Funcs[] = {\r
- {"SaveFileToDisk", (PyCFunction)SaveFileToDisk, METH_VARARGS, SaveFileToDiskDocs},\r
- {NULL, NULL, 0, NULL}\r
-};\r
-\r
-PyMODINIT_FUNC\r
-initPyUtility(VOID) {\r
- Py_InitModule3("PyUtility", PyUtility_Funcs, "Utilties Module Implemented C Language");\r
-}\r
-\r
-\r
+++ /dev/null
-## @file\r
-# package and install PyEfiCompressor extension\r
-#\r
-# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>\r
-#\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-\r
-##\r
-# Import Modules\r
-#\r
-from distutils.core import setup, Extension\r
-import os\r
-\r
-if 'BASE_TOOLS_PATH' not in os.environ:\r
- raise "Please define BASE_TOOLS_PATH to the root of base tools tree"\r
-\r
-BaseToolsDir = os.environ['BASE_TOOLS_PATH']\r
-setup(\r
- name="PyUtility",\r
- version="0.01",\r
- ext_modules=[\r
- Extension(\r
- 'PyUtility',\r
- sources=[\r
- 'PyUtility.c'\r
- ],\r
- include_dirs=[\r
- os.path.join(BaseToolsDir, 'Source', 'C', 'Include'),\r
- os.path.join(BaseToolsDir, 'Source', 'C', 'Include', 'Ia32'),\r
- os.path.join(BaseToolsDir, 'Source', 'C', 'Common')\r
- ],\r
- )\r
- ],\r
- )\r
-\r
EdkLogger.error(None, PERMISSION_FAILURE, "Do not have write permission on directory %s" % DirName)\r
\r
try:\r
- if GlobalData.gIsWindows:\r
- try:\r
- from .PyUtility import SaveFileToDisk\r
- if not SaveFileToDisk(File, Content):\r
- EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=File)\r
- except:\r
- if isinstance(Content, bytes):\r
- with open(File, "wb") as Fd:\r
- Fd.write(Content)\r
- else:\r
- with open(File, "w") as Fd:\r
- Fd.write(Content)\r
+ if isinstance(Content, bytes):\r
+ with open(File, "wb") as Fd:\r
+ Fd.write(Content)\r
else:\r
- if isinstance(Content, bytes):\r
- with open(File, "wb") as Fd:\r
- Fd.write(Content)\r
- else:\r
- with open(File, "w") as Fd:\r
- Fd.write(Content)\r
+ with open(File, "w") as Fd:\r
+ Fd.write(Content)\r
except IOError as X:\r
EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData='IOError %s' % X)\r
\r