Best Python code snippet using fMBT_python
subprocess.pyi
Source:subprocess.pyi  
1# Stubs for subprocess2# Based on http://docs.python.org/3.6/library/subprocess.html3import sys4from typing import Sequence, Any, Mapping, Callable, Tuple, IO, Optional, Union, Type, Text, Generic, TypeVar, AnyStr, overload5from types import TracebackType6if sys.version_info >= (3, 8):7    from typing import Literal8else:9    from typing_extensions import Literal10# We prefer to annotate inputs to methods (eg subprocess.check_call) with these11# union types.12# For outputs we use laborious literal based overloads to try to determine13# which specific return types to use, and prefer to fall back to Any when14# this does not work, so the caller does not have to use an assertion to confirm15# which type.16#17# For example:18#19# try:20#    x = subprocess.check_output(["ls", "-l"])21#    reveal_type(x)  # bytes, based on the overloads22# except TimeoutError as e:23#    reveal_type(e.cmd)  # Any, but morally is _CMD24_FILE = Union[None, int, IO[Any]]25_TXT = Union[bytes, Text]26if sys.version_info >= (3, 6):27    from builtins import _PathLike28    _PATH = Union[bytes, Text, _PathLike]29else:30    _PATH = Union[bytes, Text]31# Python 3.6 does't support _CMD being a single PathLike.32# See: https://bugs.python.org/issue3196133_CMD = Union[_TXT, Sequence[_PATH]]34_ENV = Union[Mapping[bytes, _TXT], Mapping[Text, _TXT]]35_S = TypeVar('_S')36_T = TypeVar('_T')37class CompletedProcess(Generic[_T]):38    # morally: _CMD39    args: Any40    returncode: int41    # These are really both Optional, but requiring checks would be tedious42    # and writing all the overloads would be horrific.43    stdout: _T44    stderr: _T45    def __init__(self, args: _CMD, returncode: int, stdout: Optional[_T] = ..., stderr: Optional[_T] = ...) -> None: ...46    def check_returncode(self) -> None: ...47if sys.version_info >= (3, 7):48    # Nearly the same args as for 3.6, except for capture_output and text49    @overload50    def run(51        args: _CMD,52        bufsize: int = ...,53        executable: _PATH = ...,54        stdin: _FILE = ...,55        stdout: _FILE = ...,56        stderr: _FILE = ...,57        preexec_fn: Callable[[], Any] = ...,58        close_fds: bool = ...,59        shell: bool = ...,60        cwd: Optional[_PATH] = ...,61        env: Optional[_ENV] = ...,62        universal_newlines: bool = ...,63        startupinfo: Any = ...,64        creationflags: int = ...,65        restore_signals: bool = ...,66        start_new_session: bool = ...,67        pass_fds: Any = ...,68        *,69        capture_output: bool = ...,70        check: bool = ...,71        encoding: Optional[str] = ...,72        errors: Optional[str] = ...,73        input: Optional[str] = ...,74        text: Literal[True],75        timeout: Optional[float] = ...,76    ) -> CompletedProcess[str]: ...77    @overload78    def run(79        args: _CMD,80        bufsize: int = ...,81        executable: _PATH = ...,82        stdin: _FILE = ...,83        stdout: _FILE = ...,84        stderr: _FILE = ...,85        preexec_fn: Callable[[], Any] = ...,86        close_fds: bool = ...,87        shell: bool = ...,88        cwd: Optional[_PATH] = ...,89        env: Optional[_ENV] = ...,90        universal_newlines: bool = ...,91        startupinfo: Any = ...,92        creationflags: int = ...,93        restore_signals: bool = ...,94        start_new_session: bool = ...,95        pass_fds: Any = ...,96        *,97        capture_output: bool = ...,98        check: bool = ...,99        encoding: str,100        errors: Optional[str] = ...,101        input: Optional[str] = ...,102        text: Optional[bool] = ...,103        timeout: Optional[float] = ...,104    ) -> CompletedProcess[str]: ...105    @overload106    def run(107        args: _CMD,108        bufsize: int = ...,109        executable: _PATH = ...,110        stdin: _FILE = ...,111        stdout: _FILE = ...,112        stderr: _FILE = ...,113        preexec_fn: Callable[[], Any] = ...,114        close_fds: bool = ...,115        shell: bool = ...,116        cwd: Optional[_PATH] = ...,117        env: Optional[_ENV] = ...,118        universal_newlines: bool = ...,119        startupinfo: Any = ...,120        creationflags: int = ...,121        restore_signals: bool = ...,122        start_new_session: bool = ...,123        pass_fds: Any = ...,124        *,125        capture_output: bool = ...,126        check: bool = ...,127        encoding: Optional[str] = ...,128        errors: str,129        input: Optional[str] = ...,130        text: Optional[bool] = ...,131        timeout: Optional[float] = ...,132    ) -> CompletedProcess[str]: ...133    @overload134    def run(135        args: _CMD,136        bufsize: int = ...,137        executable: _PATH = ...,138        stdin: _FILE = ...,139        stdout: _FILE = ...,140        stderr: _FILE = ...,141        preexec_fn: Callable[[], Any] = ...,142        close_fds: bool = ...,143        shell: bool = ...,144        cwd: Optional[_PATH] = ...,145        env: Optional[_ENV] = ...,146        *,147        universal_newlines: Literal[True],148        startupinfo: Any = ...,149        creationflags: int = ...,150        restore_signals: bool = ...,151        start_new_session: bool = ...,152        pass_fds: Any = ...,153        # where the *real* keyword only args start154        capture_output: bool = ...,155        check: bool = ...,156        encoding: Optional[str] = ...,157        errors: Optional[str] = ...,158        input: Optional[str] = ...,159        text: Optional[bool] = ...,160        timeout: Optional[float] = ...,161    ) -> CompletedProcess[str]: ...162    @overload163    def run(164        args: _CMD,165        bufsize: int = ...,166        executable: _PATH = ...,167        stdin: _FILE = ...,168        stdout: _FILE = ...,169        stderr: _FILE = ...,170        preexec_fn: Callable[[], Any] = ...,171        close_fds: bool = ...,172        shell: bool = ...,173        cwd: Optional[_PATH] = ...,174        env: Optional[_ENV] = ...,175        universal_newlines: Literal[False] = ...,176        startupinfo: Any = ...,177        creationflags: int = ...,178        restore_signals: bool = ...,179        start_new_session: bool = ...,180        pass_fds: Any = ...,181        *,182        capture_output: bool = ...,183        check: bool = ...,184        encoding: None = ...,185        errors: None = ...,186        input: Optional[bytes] = ...,187        text: Literal[None, False] = ...,188        timeout: Optional[float] = ...,189    ) -> CompletedProcess[bytes]: ...190    @overload191    def run(192        args: _CMD,193        bufsize: int = ...,194        executable: _PATH = ...,195        stdin: _FILE = ...,196        stdout: _FILE = ...,197        stderr: _FILE = ...,198        preexec_fn: Callable[[], Any] = ...,199        close_fds: bool = ...,200        shell: bool = ...,201        cwd: Optional[_PATH] = ...,202        env: Optional[_ENV] = ...,203        universal_newlines: bool = ...,204        startupinfo: Any = ...,205        creationflags: int = ...,206        restore_signals: bool = ...,207        start_new_session: bool = ...,208        pass_fds: Any = ...,209        *,210        capture_output: bool = ...,211        check: bool = ...,212        encoding: Optional[str] = ...,213        errors: Optional[str] = ...,214        input: Optional[_TXT] = ...,215        text: Optional[bool] = ...,216        timeout: Optional[float] = ...,217    ) -> CompletedProcess[Any]: ...218elif sys.version_info >= (3, 6):219    # Nearly same args as Popen.__init__ except for timeout, input, and check220    @overload221    def run(222        args: _CMD,223        bufsize: int = ...,224        executable: _PATH = ...,225        stdin: _FILE = ...,226        stdout: _FILE = ...,227        stderr: _FILE = ...,228        preexec_fn: Callable[[], Any] = ...,229        close_fds: bool = ...,230        shell: bool = ...,231        cwd: Optional[_PATH] = ...,232        env: Optional[_ENV] = ...,233        universal_newlines: bool = ...,234        startupinfo: Any = ...,235        creationflags: int = ...,236        restore_signals: bool = ...,237        start_new_session: bool = ...,238        pass_fds: Any = ...,239        *,240        check: bool = ...,241        encoding: str,242        errors: Optional[str] = ...,243        input: Optional[str] = ...,244        timeout: Optional[float] = ...,245    ) -> CompletedProcess[str]: ...246    @overload247    def run(248        args: _CMD,249        bufsize: int = ...,250        executable: _PATH = ...,251        stdin: _FILE = ...,252        stdout: _FILE = ...,253        stderr: _FILE = ...,254        preexec_fn: Callable[[], Any] = ...,255        close_fds: bool = ...,256        shell: bool = ...,257        cwd: Optional[_PATH] = ...,258        env: Optional[_ENV] = ...,259        universal_newlines: bool = ...,260        startupinfo: Any = ...,261        creationflags: int = ...,262        restore_signals: bool = ...,263        start_new_session: bool = ...,264        pass_fds: Any = ...,265        *,266        check: bool = ...,267        encoding: Optional[str] = ...,268        errors: str,269        input: Optional[str] = ...,270        timeout: Optional[float] = ...,271    ) -> CompletedProcess[str]: ...272    @overload273    def run(274        args: _CMD,275        bufsize: int = ...,276        executable: _PATH = ...,277        stdin: _FILE = ...,278        stdout: _FILE = ...,279        stderr: _FILE = ...,280        preexec_fn: Callable[[], Any] = ...,281        close_fds: bool = ...,282        shell: bool = ...,283        cwd: Optional[_PATH] = ...,284        env: Optional[_ENV] = ...,285        *,286        universal_newlines: Literal[True],287        startupinfo: Any = ...,288        creationflags: int = ...,289        restore_signals: bool = ...,290        start_new_session: bool = ...,291        pass_fds: Any = ...,292        # where the *real* keyword only args start293        check: bool = ...,294        encoding: Optional[str] = ...,295        errors: Optional[str] = ...,296        input: Optional[str] = ...,297        timeout: Optional[float] = ...,298    ) -> CompletedProcess[str]: ...299    @overload300    def run(301        args: _CMD,302        bufsize: int = ...,303        executable: _PATH = ...,304        stdin: _FILE = ...,305        stdout: _FILE = ...,306        stderr: _FILE = ...,307        preexec_fn: Callable[[], Any] = ...,308        close_fds: bool = ...,309        shell: bool = ...,310        cwd: Optional[_PATH] = ...,311        env: Optional[_ENV] = ...,312        universal_newlines: Literal[False] = ...,313        startupinfo: Any = ...,314        creationflags: int = ...,315        restore_signals: bool = ...,316        start_new_session: bool = ...,317        pass_fds: Any = ...,318        *,319        check: bool = ...,320        encoding: None = ...,321        errors: None = ...,322        input: Optional[bytes] = ...,323        timeout: Optional[float] = ...,324    ) -> CompletedProcess[bytes]: ...325    @overload326    def run(327        args: _CMD,328        bufsize: int = ...,329        executable: _PATH = ...,330        stdin: _FILE = ...,331        stdout: _FILE = ...,332        stderr: _FILE = ...,333        preexec_fn: Callable[[], Any] = ...,334        close_fds: bool = ...,335        shell: bool = ...,336        cwd: Optional[_PATH] = ...,337        env: Optional[_ENV] = ...,338        universal_newlines: bool = ...,339        startupinfo: Any = ...,340        creationflags: int = ...,341        restore_signals: bool = ...,342        start_new_session: bool = ...,343        pass_fds: Any = ...,344        *,345        check: bool = ...,346        encoding: Optional[str] = ...,347        errors: Optional[str] = ...,348        input: Optional[_TXT] = ...,349        timeout: Optional[float] = ...,350    ) -> CompletedProcess[Any]: ...351else:352    # Nearly same args as Popen.__init__ except for timeout, input, and check353    @overload354    def run(355        args: _CMD,356        bufsize: int = ...,357        executable: _PATH = ...,358        stdin: _FILE = ...,359        stdout: _FILE = ...,360        stderr: _FILE = ...,361        preexec_fn: Callable[[], Any] = ...,362        close_fds: bool = ...,363        shell: bool = ...,364        cwd: Optional[_PATH] = ...,365        env: Optional[_ENV] = ...,366        *,367        universal_newlines: Literal[True],368        startupinfo: Any = ...,369        creationflags: int = ...,370        restore_signals: bool = ...,371        start_new_session: bool = ...,372        pass_fds: Any = ...,373        # where the *real* keyword only args start374        check: bool = ...,375        input: Optional[str] = ...,376        timeout: Optional[float] = ...,377    ) -> CompletedProcess[str]: ...378    @overload379    def run(380        args: _CMD,381        bufsize: int = ...,382        executable: _PATH = ...,383        stdin: _FILE = ...,384        stdout: _FILE = ...,385        stderr: _FILE = ...,386        preexec_fn: Callable[[], Any] = ...,387        close_fds: bool = ...,388        shell: bool = ...,389        cwd: Optional[_PATH] = ...,390        env: Optional[_ENV] = ...,391        universal_newlines: Literal[False] = ...,392        startupinfo: Any = ...,393        creationflags: int = ...,394        restore_signals: bool = ...,395        start_new_session: bool = ...,396        pass_fds: Any = ...,397        *,398        check: bool = ...,399        input: Optional[bytes] = ...,400        timeout: Optional[float] = ...,401    ) -> CompletedProcess[bytes]: ...402    @overload403    def run(404        args: _CMD,405        bufsize: int = ...,406        executable: _PATH = ...,407        stdin: _FILE = ...,408        stdout: _FILE = ...,409        stderr: _FILE = ...,410        preexec_fn: Callable[[], Any] = ...,411        close_fds: bool = ...,412        shell: bool = ...,413        cwd: Optional[_PATH] = ...,414        env: Optional[_ENV] = ...,415        universal_newlines: bool = ...,416        startupinfo: Any = ...,417        creationflags: int = ...,418        restore_signals: bool = ...,419        start_new_session: bool = ...,420        pass_fds: Any = ...,421        *,422        check: bool = ...,423        input: Optional[_TXT] = ...,424        timeout: Optional[float] = ...,425    ) -> CompletedProcess[Any]: ...426# Same args as Popen.__init__427def call(args: _CMD,428         bufsize: int = ...,429         executable: _PATH = ...,430         stdin: _FILE = ...,431         stdout: _FILE = ...,432         stderr: _FILE = ...,433         preexec_fn: Callable[[], Any] = ...,434         close_fds: bool = ...,435         shell: bool = ...,436         cwd: Optional[_PATH] = ...,437         env: Optional[_ENV] = ...,438         universal_newlines: bool = ...,439         startupinfo: Any = ...,440         creationflags: int = ...,441         restore_signals: bool = ...,442         start_new_session: bool = ...,443         pass_fds: Any = ...,444         timeout: Optional[float] = ...) -> int: ...445# Same args as Popen.__init__446def check_call(args: _CMD,447               bufsize: int = ...,448               executable: _PATH = ...,449               stdin: _FILE = ...,450               stdout: _FILE = ...,451               stderr: _FILE = ...,452               preexec_fn: Callable[[], Any] = ...,453               close_fds: bool = ...,454               shell: bool = ...,455               cwd: Optional[_PATH] = ...,456               env: Optional[_ENV] = ...,457               universal_newlines: bool = ...,458               startupinfo: Any = ...,459               creationflags: int = ...,460               restore_signals: bool = ...,461               start_new_session: bool = ...,462               pass_fds: Any = ...,463               timeout: Optional[float] = ...) -> int: ...464if sys.version_info >= (3, 7):465    # 3.7 added text466    @overload467    def check_output(args: _CMD,468                     bufsize: int = ...,469                     executable: _PATH = ...,470                     stdin: _FILE = ...,471                     stderr: _FILE = ...,472                     preexec_fn: Callable[[], Any] = ...,473                     close_fds: bool = ...,474                     shell: bool = ...,475                     cwd: Optional[_PATH] = ...,476                     env: Optional[_ENV] = ...,477                     universal_newlines: bool = ...,478                     startupinfo: Any = ...,479                     creationflags: int = ...,480                     restore_signals: bool = ...,481                     start_new_session: bool = ...,482                     pass_fds: Any = ...,483                     *,484                     timeout: Optional[float] = ...,485                     input: _TXT = ...,486                     encoding: Optional[str] = ...,487                     errors: Optional[str] = ...,488                     text: Literal[True],489                     ) -> str: ...490    @overload491    def check_output(args: _CMD,492                     bufsize: int = ...,493                     executable: _PATH = ...,494                     stdin: _FILE = ...,495                     stderr: _FILE = ...,496                     preexec_fn: Callable[[], Any] = ...,497                     close_fds: bool = ...,498                     shell: bool = ...,499                     cwd: Optional[_PATH] = ...,500                     env: Optional[_ENV] = ...,501                     universal_newlines: bool = ...,502                     startupinfo: Any = ...,503                     creationflags: int = ...,504                     restore_signals: bool = ...,505                     start_new_session: bool = ...,506                     pass_fds: Any = ...,507                     *,508                     timeout: Optional[float] = ...,509                     input: _TXT = ...,510                     encoding: str,511                     errors: Optional[str] = ...,512                     text: Optional[bool] = ...,513                     ) -> str: ...514    @overload515    def check_output(args: _CMD,516                     bufsize: int = ...,517                     executable: _PATH = ...,518                     stdin: _FILE = ...,519                     stderr: _FILE = ...,520                     preexec_fn: Callable[[], Any] = ...,521                     close_fds: bool = ...,522                     shell: bool = ...,523                     cwd: Optional[_PATH] = ...,524                     env: Optional[_ENV] = ...,525                     universal_newlines: bool = ...,526                     startupinfo: Any = ...,527                     creationflags: int = ...,528                     restore_signals: bool = ...,529                     start_new_session: bool = ...,530                     pass_fds: Any = ...,531                     *,532                     timeout: Optional[float] = ...,533                     input: _TXT = ...,534                     encoding: Optional[str] = ...,535                     errors: str,536                     text: Optional[bool] = ...,537                     ) -> str: ...538    @overload539    def check_output(args: _CMD,540                     bufsize: int = ...,541                     executable: _PATH = ...,542                     stdin: _FILE = ...,543                     stderr: _FILE = ...,544                     preexec_fn: Callable[[], Any] = ...,545                     close_fds: bool = ...,546                     shell: bool = ...,547                     cwd: Optional[_PATH] = ...,548                     env: Optional[_ENV] = ...,549                     *,550                     universal_newlines: Literal[True],551                     startupinfo: Any = ...,552                     creationflags: int = ...,553                     restore_signals: bool = ...,554                     start_new_session: bool = ...,555                     pass_fds: Any = ...,556                     # where the real keyword only ones start557                     timeout: Optional[float] = ...,558                     input: _TXT = ...,559                     encoding: Optional[str] = ...,560                     errors: Optional[str] = ...,561                     text: Optional[bool] = ...,562                     ) -> str: ...563    @overload564    def check_output(args: _CMD,565                     bufsize: int = ...,566                     executable: _PATH = ...,567                     stdin: _FILE = ...,568                     stderr: _FILE = ...,569                     preexec_fn: Callable[[], Any] = ...,570                     close_fds: bool = ...,571                     shell: bool = ...,572                     cwd: Optional[_PATH] = ...,573                     env: Optional[_ENV] = ...,574                     universal_newlines: Literal[False] = ...,575                     startupinfo: Any = ...,576                     creationflags: int = ...,577                     restore_signals: bool = ...,578                     start_new_session: bool = ...,579                     pass_fds: Any = ...,580                     *,581                     timeout: Optional[float] = ...,582                     input: _TXT = ...,583                     encoding: None = ...,584                     errors: None = ...,585                     text: Literal[None, False] = ...,586                     ) -> bytes: ...587    @overload588    def check_output(args: _CMD,589                     bufsize: int = ...,590                     executable: _PATH = ...,591                     stdin: _FILE = ...,592                     stderr: _FILE = ...,593                     preexec_fn: Callable[[], Any] = ...,594                     close_fds: bool = ...,595                     shell: bool = ...,596                     cwd: Optional[_PATH] = ...,597                     env: Optional[_ENV] = ...,598                     universal_newlines: bool = ...,599                     startupinfo: Any = ...,600                     creationflags: int = ...,601                     restore_signals: bool = ...,602                     start_new_session: bool = ...,603                     pass_fds: Any = ...,604                     *,605                     timeout: Optional[float] = ...,606                     input: _TXT = ...,607                     encoding: Optional[str] = ...,608                     errors: Optional[str] = ...,609                     text: Optional[bool] = ...,610                     ) -> Any: ...  # morally: -> _TXT611elif sys.version_info >= (3, 6):612    # 3.6 added encoding and errors613    @overload614    def check_output(args: _CMD,615                     bufsize: int = ...,616                     executable: _PATH = ...,617                     stdin: _FILE = ...,618                     stderr: _FILE = ...,619                     preexec_fn: Callable[[], Any] = ...,620                     close_fds: bool = ...,621                     shell: bool = ...,622                     cwd: Optional[_PATH] = ...,623                     env: Optional[_ENV] = ...,624                     universal_newlines: bool = ...,625                     startupinfo: Any = ...,626                     creationflags: int = ...,627                     restore_signals: bool = ...,628                     start_new_session: bool = ...,629                     pass_fds: Any = ...,630                     *,631                     timeout: Optional[float] = ...,632                     input: _TXT = ...,633                     encoding: str,634                     errors: Optional[str] = ...,635                     ) -> str: ...636    @overload637    def check_output(args: _CMD,638                     bufsize: int = ...,639                     executable: _PATH = ...,640                     stdin: _FILE = ...,641                     stderr: _FILE = ...,642                     preexec_fn: Callable[[], Any] = ...,643                     close_fds: bool = ...,644                     shell: bool = ...,645                     cwd: Optional[_PATH] = ...,646                     env: Optional[_ENV] = ...,647                     universal_newlines: bool = ...,648                     startupinfo: Any = ...,649                     creationflags: int = ...,650                     restore_signals: bool = ...,651                     start_new_session: bool = ...,652                     pass_fds: Any = ...,653                     *,654                     timeout: Optional[float] = ...,655                     input: _TXT = ...,656                     encoding: Optional[str] = ...,657                     errors: str,658                     ) -> str: ...659    @overload660    def check_output(args: _CMD,661                     bufsize: int = ...,662                     executable: _PATH = ...,663                     stdin: _FILE = ...,664                     stderr: _FILE = ...,665                     preexec_fn: Callable[[], Any] = ...,666                     close_fds: bool = ...,667                     shell: bool = ...,668                     cwd: Optional[_PATH] = ...,669                     env: Optional[_ENV] = ...,670                     startupinfo: Any = ...,671                     creationflags: int = ...,672                     restore_signals: bool = ...,673                     start_new_session: bool = ...,674                     pass_fds: Any = ...,675                     *,676                     universal_newlines: Literal[True],677                     timeout: Optional[float] = ...,678                     input: _TXT = ...,679                     encoding: Optional[str] = ...,680                     errors: Optional[str] = ...,681                     ) -> str: ...682    @overload683    def check_output(args: _CMD,684                     bufsize: int = ...,685                     executable: _PATH = ...,686                     stdin: _FILE = ...,687                     stderr: _FILE = ...,688                     preexec_fn: Callable[[], Any] = ...,689                     close_fds: bool = ...,690                     shell: bool = ...,691                     cwd: Optional[_PATH] = ...,692                     env: Optional[_ENV] = ...,693                     universal_newlines: Literal[False] = ...,694                     startupinfo: Any = ...,695                     creationflags: int = ...,696                     restore_signals: bool = ...,697                     start_new_session: bool = ...,698                     pass_fds: Any = ...,699                     *,700                     timeout: Optional[float] = ...,701                     input: _TXT = ...,702                     encoding: None = ...,703                     errors: None = ...,704                     ) -> bytes: ...705    @overload706    def check_output(args: _CMD,707                     bufsize: int = ...,708                     executable: _PATH = ...,709                     stdin: _FILE = ...,710                     stderr: _FILE = ...,711                     preexec_fn: Callable[[], Any] = ...,712                     close_fds: bool = ...,713                     shell: bool = ...,714                     cwd: Optional[_PATH] = ...,715                     env: Optional[_ENV] = ...,716                     universal_newlines: bool = ...,717                     startupinfo: Any = ...,718                     creationflags: int = ...,719                     restore_signals: bool = ...,720                     start_new_session: bool = ...,721                     pass_fds: Any = ...,722                     *,723                     timeout: Optional[float] = ...,724                     input: _TXT = ...,725                     encoding: Optional[str] = ...,726                     errors: Optional[str] = ...,727                     ) -> Any: ...  # morally: -> _TXT728else:729    @overload730    def check_output(args: _CMD,731                     bufsize: int = ...,732                     executable: _PATH = ...,733                     stdin: _FILE = ...,734                     stderr: _FILE = ...,735                     preexec_fn: Callable[[], Any] = ...,736                     close_fds: bool = ...,737                     shell: bool = ...,738                     cwd: Optional[_PATH] = ...,739                     env: Optional[_ENV] = ...,740                     startupinfo: Any = ...,741                     creationflags: int = ...,742                     restore_signals: bool = ...,743                     start_new_session: bool = ...,744                     pass_fds: Any = ...,745                     timeout: Optional[float] = ...,746                     input: _TXT = ...,747                     *,748                     universal_newlines: Literal[True],749                     ) -> str: ...750    @overload751    def check_output(args: _CMD,752                     bufsize: int = ...,753                     executable: _PATH = ...,754                     stdin: _FILE = ...,755                     stderr: _FILE = ...,756                     preexec_fn: Callable[[], Any] = ...,757                     close_fds: bool = ...,758                     shell: bool = ...,759                     cwd: Optional[_PATH] = ...,760                     env: Optional[_ENV] = ...,761                     universal_newlines: Literal[False] = ...,762                     startupinfo: Any = ...,763                     creationflags: int = ...,764                     restore_signals: bool = ...,765                     start_new_session: bool = ...,766                     pass_fds: Any = ...,767                     timeout: Optional[float] = ...,768                     input: _TXT = ...,769                     ) -> bytes: ...770    @overload771    def check_output(args: _CMD,772                     bufsize: int = ...,773                     executable: _PATH = ...,774                     stdin: _FILE = ...,775                     stderr: _FILE = ...,776                     preexec_fn: Callable[[], Any] = ...,777                     close_fds: bool = ...,778                     shell: bool = ...,779                     cwd: Optional[_PATH] = ...,780                     env: Optional[_ENV] = ...,781                     universal_newlines: bool = ...,782                     startupinfo: Any = ...,783                     creationflags: int = ...,784                     restore_signals: bool = ...,785                     start_new_session: bool = ...,786                     pass_fds: Any = ...,787                     timeout: Optional[float] = ...,788                     input: _TXT = ...,789                     ) -> Any: ...  # morally: -> _TXT790PIPE: int791STDOUT: int792DEVNULL: int793class SubprocessError(Exception): ...794class TimeoutExpired(SubprocessError):795    def __init__(self, cmd: _CMD, timeout: float, output: Optional[_TXT] = ..., stderr: Optional[_TXT] = ...) -> None: ...796    # morally: _CMD797    cmd: Any798    timeout: float799    # morally: Optional[_TXT]800    output: Any801    stdout: Any802    stderr: Any803class CalledProcessError(Exception):804    returncode: int805    # morally: _CMD806    cmd: Any807    # morally: Optional[_TXT]808    output: Any809    # morally: Optional[_TXT]810    stdout: Any811    stderr: Any812    def __init__(self,813                 returncode: int,814                 cmd: _CMD,815                 output: Optional[_TXT] = ...,816                 stderr: Optional[_TXT] = ...) -> None: ...817class Popen(Generic[AnyStr]):818    args: _CMD819    stdin: IO[AnyStr]820    stdout: IO[AnyStr]821    stderr: IO[AnyStr]822    pid: int823    returncode: int824    # Technically it is wrong that Popen provides __new__ instead of __init__825    # but this shouldn't come up hopefully?826    if sys.version_info >= (3, 7):827        # text is added in 3.7828        @overload829        def __new__(cls,830                    args: _CMD,831                    bufsize: int = ...,832                    executable: Optional[_PATH] = ...,833                    stdin: Optional[_FILE] = ...,834                    stdout: Optional[_FILE] = ...,835                    stderr: Optional[_FILE] = ...,836                    preexec_fn: Optional[Callable[[], Any]] = ...,837                    close_fds: bool = ...,838                    shell: bool = ...,839                    cwd: Optional[_PATH] = ...,840                    env: Optional[_ENV] = ...,841                    universal_newlines: bool = ...,842                    startupinfo: Optional[Any] = ...,843                    creationflags: int = ...,844                    restore_signals: bool = ...,845                    start_new_session: bool = ...,846                    pass_fds: Any = ...,847                    *,848                    text: Optional[bool] = ...,849                    encoding: str,850                    errors: Optional[str] = ...) -> Popen[str]: ...851        @overload852        def __new__(cls,853                    args: _CMD,854                    bufsize: int = ...,855                    executable: Optional[_PATH] = ...,856                    stdin: Optional[_FILE] = ...,857                    stdout: Optional[_FILE] = ...,858                    stderr: Optional[_FILE] = ...,859                    preexec_fn: Optional[Callable[[], Any]] = ...,860                    close_fds: bool = ...,861                    shell: bool = ...,862                    cwd: Optional[_PATH] = ...,863                    env: Optional[_ENV] = ...,864                    universal_newlines: bool = ...,865                    startupinfo: Optional[Any] = ...,866                    creationflags: int = ...,867                    restore_signals: bool = ...,868                    start_new_session: bool = ...,869                    pass_fds: Any = ...,870                    *,871                    text: Optional[bool] = ...,872                    encoding: Optional[str] = ...,873                    errors: str) -> Popen[str]: ...874        @overload875        def __new__(cls,876                    args: _CMD,877                    bufsize: int = ...,878                    executable: Optional[_PATH] = ...,879                    stdin: Optional[_FILE] = ...,880                    stdout: Optional[_FILE] = ...,881                    stderr: Optional[_FILE] = ...,882                    preexec_fn: Optional[Callable[[], Any]] = ...,883                    close_fds: bool = ...,884                    shell: bool = ...,885                    cwd: Optional[_PATH] = ...,886                    env: Optional[_ENV] = ...,887                    *,888                    universal_newlines: Literal[True],889                    startupinfo: Optional[Any] = ...,890                    creationflags: int = ...,891                    restore_signals: bool = ...,892                    start_new_session: bool = ...,893                    pass_fds: Any = ...,894                    # where the *real* keyword only args start895                    text: Optional[bool] = ...,896                    encoding: Optional[str] = ...,897                    errors: Optional[str] = ...) -> Popen[str]: ...898        @overload899        def __new__(cls,900                    args: _CMD,901                    bufsize: int = ...,902                    executable: Optional[_PATH] = ...,903                    stdin: Optional[_FILE] = ...,904                    stdout: Optional[_FILE] = ...,905                    stderr: Optional[_FILE] = ...,906                    preexec_fn: Optional[Callable[[], Any]] = ...,907                    close_fds: bool = ...,908                    shell: bool = ...,909                    cwd: Optional[_PATH] = ...,910                    env: Optional[_ENV] = ...,911                    universal_newlines: bool = ...,912                    startupinfo: Optional[Any] = ...,913                    creationflags: int = ...,914                    restore_signals: bool = ...,915                    start_new_session: bool = ...,916                    pass_fds: Any = ...,917                    *,918                    text: Literal[True],919                    encoding: Optional[str] = ...,920                    errors: Optional[str] = ...) -> Popen[str]: ...921        @overload922        def __new__(cls,923                    args: _CMD,924                    bufsize: int = ...,925                    executable: Optional[_PATH] = ...,926                    stdin: Optional[_FILE] = ...,927                    stdout: Optional[_FILE] = ...,928                    stderr: Optional[_FILE] = ...,929                    preexec_fn: Optional[Callable[[], Any]] = ...,930                    close_fds: bool = ...,931                    shell: bool = ...,932                    cwd: Optional[_PATH] = ...,933                    env: Optional[_ENV] = ...,934                    universal_newlines: Literal[False] = ...,935                    startupinfo: Optional[Any] = ...,936                    creationflags: int = ...,937                    restore_signals: bool = ...,938                    start_new_session: bool = ...,939                    pass_fds: Any = ...,940                    *,941                    text: Literal[None, False] = ...,942                    encoding: None = ...,943                    errors: None = ...) -> Popen[bytes]: ...944        @overload945        def __new__(cls,946                    args: _CMD,947                    bufsize: int = ...,948                    executable: Optional[_PATH] = ...,949                    stdin: Optional[_FILE] = ...,950                    stdout: Optional[_FILE] = ...,951                    stderr: Optional[_FILE] = ...,952                    preexec_fn: Optional[Callable[[], Any]] = ...,953                    close_fds: bool = ...,954                    shell: bool = ...,955                    cwd: Optional[_PATH] = ...,956                    env: Optional[_ENV] = ...,957                    universal_newlines: bool = ...,958                    startupinfo: Optional[Any] = ...,959                    creationflags: int = ...,960                    restore_signals: bool = ...,961                    start_new_session: bool = ...,962                    pass_fds: Any = ...,963                    *,964                    text: Optional[bool] = ...,965                    encoding: Optional[str] = ...,966                    errors: Optional[str] = ...) -> Popen[Any]: ...967    elif sys.version_info >= (3, 6):968        @overload969        def __new__(cls,970                    args: _CMD,971                    bufsize: int = ...,972                    executable: Optional[_PATH] = ...,973                    stdin: Optional[_FILE] = ...,974                    stdout: Optional[_FILE] = ...,975                    stderr: Optional[_FILE] = ...,976                    preexec_fn: Optional[Callable[[], Any]] = ...,977                    close_fds: bool = ...,978                    shell: bool = ...,979                    cwd: Optional[_PATH] = ...,980                    env: Optional[_ENV] = ...,981                    universal_newlines: bool = ...,982                    startupinfo: Optional[Any] = ...,983                    creationflags: int = ...,984                    restore_signals: bool = ...,985                    start_new_session: bool = ...,986                    pass_fds: Any = ...,987                    *,988                    encoding: str,989                    errors: Optional[str] = ...) -> Popen[str]: ...990        @overload991        def __new__(cls,992                    args: _CMD,993                    bufsize: int = ...,994                    executable: Optional[_PATH] = ...,995                    stdin: Optional[_FILE] = ...,996                    stdout: Optional[_FILE] = ...,997                    stderr: Optional[_FILE] = ...,998                    preexec_fn: Optional[Callable[[], Any]] = ...,999                    close_fds: bool = ...,1000                    shell: bool = ...,1001                    cwd: Optional[_PATH] = ...,1002                    env: Optional[_ENV] = ...,1003                    universal_newlines: bool = ...,1004                    startupinfo: Optional[Any] = ...,1005                    creationflags: int = ...,1006                    restore_signals: bool = ...,1007                    start_new_session: bool = ...,1008                    pass_fds: Any = ...,1009                    *,1010                    encoding: Optional[str] = ...,1011                    errors: str) -> Popen[str]: ...1012        @overload1013        def __new__(cls,1014                    args: _CMD,1015                    bufsize: int = ...,1016                    executable: Optional[_PATH] = ...,1017                    stdin: Optional[_FILE] = ...,1018                    stdout: Optional[_FILE] = ...,1019                    stderr: Optional[_FILE] = ...,1020                    preexec_fn: Optional[Callable[[], Any]] = ...,1021                    close_fds: bool = ...,1022                    shell: bool = ...,1023                    cwd: Optional[_PATH] = ...,1024                    env: Optional[_ENV] = ...,1025                    *,1026                    universal_newlines: Literal[True],1027                    startupinfo: Optional[Any] = ...,1028                    creationflags: int = ...,1029                    restore_signals: bool = ...,1030                    start_new_session: bool = ...,1031                    pass_fds: Any = ...,1032                    # where the *real* keyword only args start1033                    encoding: Optional[str] = ...,1034                    errors: Optional[str] = ...) -> Popen[str]: ...1035        @overload1036        def __new__(cls,1037                    args: _CMD,1038                    bufsize: int = ...,1039                    executable: Optional[_PATH] = ...,1040                    stdin: Optional[_FILE] = ...,1041                    stdout: Optional[_FILE] = ...,1042                    stderr: Optional[_FILE] = ...,1043                    preexec_fn: Optional[Callable[[], Any]] = ...,1044                    close_fds: bool = ...,1045                    shell: bool = ...,1046                    cwd: Optional[_PATH] = ...,1047                    env: Optional[_ENV] = ...,1048                    universal_newlines: Literal[False] = ...,1049                    startupinfo: Optional[Any] = ...,1050                    creationflags: int = ...,1051                    restore_signals: bool = ...,1052                    start_new_session: bool = ...,1053                    pass_fds: Any = ...,1054                    *,1055                    encoding: None = ...,1056                    errors: None = ...) -> Popen[bytes]: ...1057        @overload1058        def __new__(cls,1059                    args: _CMD,1060                    bufsize: int = ...,1061                    executable: Optional[_PATH] = ...,1062                    stdin: Optional[_FILE] = ...,1063                    stdout: Optional[_FILE] = ...,1064                    stderr: Optional[_FILE] = ...,1065                    preexec_fn: Optional[Callable[[], Any]] = ...,1066                    close_fds: bool = ...,1067                    shell: bool = ...,1068                    cwd: Optional[_PATH] = ...,1069                    env: Optional[_ENV] = ...,1070                    universal_newlines: bool = ...,1071                    startupinfo: Optional[Any] = ...,1072                    creationflags: int = ...,1073                    restore_signals: bool = ...,1074                    start_new_session: bool = ...,1075                    pass_fds: Any = ...,1076                    *,1077                    encoding: Optional[str] = ...,1078                    errors: Optional[str] = ...) -> Popen[Any]: ...1079    else:1080        @overload1081        def __new__(cls,1082                    args: _CMD,1083                    bufsize: int = ...,1084                    executable: Optional[_PATH] = ...,1085                    stdin: Optional[_FILE] = ...,1086                    stdout: Optional[_FILE] = ...,1087                    stderr: Optional[_FILE] = ...,1088                    preexec_fn: Optional[Callable[[], Any]] = ...,1089                    close_fds: bool = ...,1090                    shell: bool = ...,1091                    cwd: Optional[_PATH] = ...,1092                    env: Optional[_ENV] = ...,1093                    *,1094                    universal_newlines: Literal[True],1095                    startupinfo: Optional[Any] = ...,1096                    creationflags: int = ...,1097                    restore_signals: bool = ...,1098                    start_new_session: bool = ...,1099                    pass_fds: Any = ...) -> Popen[str]: ...1100        @overload1101        def __new__(cls,1102                    args: _CMD,1103                    bufsize: int = ...,1104                    executable: Optional[_PATH] = ...,1105                    stdin: Optional[_FILE] = ...,1106                    stdout: Optional[_FILE] = ...,1107                    stderr: Optional[_FILE] = ...,1108                    preexec_fn: Optional[Callable[[], Any]] = ...,1109                    close_fds: bool = ...,1110                    shell: bool = ...,1111                    cwd: Optional[_PATH] = ...,1112                    env: Optional[_ENV] = ...,1113                    *,1114                    universal_newlines: Literal[False] = ...,1115                    startupinfo: Optional[Any] = ...,1116                    creationflags: int = ...,1117                    restore_signals: bool = ...,1118                    start_new_session: bool = ...,1119                    pass_fds: Any = ...) -> Popen[bytes]: ...1120        @overload1121        def __new__(cls,1122                    args: _CMD,1123                    bufsize: int = ...,1124                    executable: Optional[_PATH] = ...,1125                    stdin: Optional[_FILE] = ...,1126                    stdout: Optional[_FILE] = ...,1127                    stderr: Optional[_FILE] = ...,1128                    preexec_fn: Optional[Callable[[], Any]] = ...,1129                    close_fds: bool = ...,1130                    shell: bool = ...,1131                    cwd: Optional[_PATH] = ...,1132                    env: Optional[_ENV] = ...,1133                    universal_newlines: bool = ...,1134                    startupinfo: Optional[Any] = ...,1135                    creationflags: int = ...,1136                    restore_signals: bool = ...,1137                    start_new_session: bool = ...,1138                    pass_fds: Any = ...) -> Popen[Any]: ...1139    def poll(self) -> int: ...1140    def wait(self, timeout: Optional[float] = ...) -> int: ...1141    # Return str/bytes1142    def communicate(self,1143                    input: Optional[AnyStr] = ...,1144                    timeout: Optional[float] = ...,1145                    # morally this should be optional1146                    ) -> Tuple[AnyStr, AnyStr]: ...1147    def send_signal(self, signal: int) -> None: ...1148    def terminate(self) -> None: ...1149    def kill(self) -> None: ...1150    def __enter__(self: _S) -> _S: ...1151    def __exit__(self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]) -> None: ...1152# The result really is always a str.1153def getstatusoutput(cmd: _TXT) -> Tuple[int, str]: ...1154def getoutput(cmd: _TXT) -> str: ...1155def list2cmdline(seq: Sequence[str]) -> str: ...  # undocumented1156if sys.platform == 'win32':1157    class STARTUPINFO:1158        if sys.version_info >= (3, 7):1159            def __init__(self, *, dwFlags: int = ..., hStdInput: Optional[Any] = ..., hStdOutput: Optional[Any] = ..., hStdError: Optional[Any] = ..., wShowWindow: int = ..., lpAttributeList: Optional[Mapping[str, Any]] = ...) -> None: ...1160        dwFlags: int1161        hStdInput: Optional[Any]1162        hStdOutput: Optional[Any]1163        hStdError: Optional[Any]1164        wShowWindow: int1165        if sys.version_info >= (3, 7):1166            lpAttributeList: Mapping[str, Any]1167    STD_INPUT_HANDLE: Any1168    STD_OUTPUT_HANDLE: Any1169    STD_ERROR_HANDLE: Any1170    SW_HIDE: int1171    STARTF_USESTDHANDLES: int1172    STARTF_USESHOWWINDOW: int1173    CREATE_NEW_CONSOLE: int1174    CREATE_NEW_PROCESS_GROUP: int1175    if sys.version_info >= (3, 7):1176        ABOVE_NORMAL_PRIORITY_CLASS: int1177        BELOW_NORMAL_PRIORITY_CLASS: int1178        HIGH_PRIORITY_CLASS: int1179        IDLE_PRIORITY_CLASS: int1180        NORMAL_PRIORITY_CLASS: int1181        REALTIME_PRIORITY_CLASS: int1182        CREATE_NO_WINDOW: int1183        DETACHED_PROCESS: int1184        CREATE_DEFAULT_ERROR_MODE: int...exportVTK.py
Source:exportVTK.py  
1# ======================================2# Code created by DSc. Gustavo Rabello 3# and modificated by Leandro Marques4# Gesar Search Group5# State University of the Rio de Janeiro6# e-mail: gustavo.rabello@uerj.br7# e-mail: marquesleandro67@gmail.com8# ======================================9# This code is used to export vtkfile for paraview visualization10# -----------------------------------------------------------------------------------------11# Use:12# save = export_vtk.Linear2D(mesh.x,mesh.y,mesh.IEN,mesh.npoints,mesh.nelem,s1,s2,s3,v1,v2)13# save.create_dir(directory_name)14# save.saveVTK(file_simulation + str(t))15# -----------------------------------------------------------------------------------------16import numpy as np17import os18class Linear1D:19 def __init__(_self,_x,_IEN,_npoints,_nelem,_scalar1,_scalar2,_scalar3,_vec1,_vec2):20  _self.x = _x21  _self.IEN = _IEN22  _self.npoints = _npoints23  _self.nelem = _nelem24  _self.scalar1 = _scalar125  _self.scalar2 = _scalar226  _self.scalar3 = _scalar327  _self.vec1 = _vec128  _self.vec2 = _vec229 def create_dir(_self,_dir):30  _self.path = os.getcwd()31  # make result directory32  if not 'results' in os.listdir(_self.path):33   os.mkdir(_self.path + '/results')34  # make save directory35  _self.path = _self.path + '/results'36  if not _dir in os.listdir(_self.path):37   _self.dir = _dir38   os.mkdir(_self.path + '/' + _self.dir)39  else:40   _self.dir = _dir41  _self.path = _self.path + '/' + _self.dir42 def saveVTK(_self,_file):43  vtkFile = open(_self.path + '/' + _file + '.vtk', 'w')44  _self.vtkHeader(vtkFile)45  _self.vtkCoords(vtkFile)46  _self.vtkCellArray(vtkFile)47  _self.vtkCellType(vtkFile)48  _self.vtkScalarScalarHeader(vtkFile)49  _self.vtkVector(vtkFile,'vector', _self.vec1, _self.vec2)50  if _self.scalar1 is not None:51   _self.vtkScalar(vtkFile,"scalar1",_self.scalar1);52  53  if _self.scalar2 is not None:54   _self.vtkScalar(vtkFile,"scalar2",_self.scalar2);55  if _self.scalar3 is not None:56   _self.vtkScalar(vtkFile,"scalar3",_self.scalar3);57  vtkFile.close()58 def vtkHeader(_self,_file,_iter=None):59  _file.write( "# vtk DataFile Version 2.0\n" )60  _file.write( "1D Simulation Python\n" )61  _file.write( "ASCII\n" )62  _file.write( "DATASET UNSTRUCTURED_GRID\n" )63  _file.write( "FIELD FieldData 1\n" )64  _file.write( "NODES 1 2 int\n" )65  _file.write( str(_self.npoints) + " " + \66               str(_self.nelem) + "\n" )67  _file.write( "\n" )68 def vtkCoords(_self,_file):69  _file.write( "POINTS " + str(_self.npoints) + " double\n" )70  for i in range(0,_self.npoints):71   _file.write( str(_self.x[i][0]) + " 0.0" + " 0.0\n" )72  _file.write( "\n" )73 def vtkCellArray(_self,_file):74  _file.write( "CELLS " + str(_self.nelem) \75                        + " " + str(3*_self.nelem) + "\n" )76  for i in range(0,_self.nelem):77   _file.write( "2 " + str(_self.IEN[i][0]) + " " + \78                       str(_self.IEN[i][1]) + "\n" )79  _file.write( "\n" )80 def vtkCellType(_self,_file):81  _file.write( "CELL_TYPES " + str(_self.nelem) + "\n" )82  for i in range(0,_self.nelem):83   _file.write( "3 ")84   _file.write( "\n" )85 86  _file.write( "\n" )87   88 def vtkScalarHeader(_self,_file):89  _file.write( "POINT_DATA " + str(_self.npoints) + "\n" )90  _file.write( "\n" )91 def vtkScalarScalarHeader(_self,_file):92  _file.write( "POINT_DATA " + str(_self.npoints) + "\n" )93 def vtkScalar(_self,_file,_name,_scalar):94  _file.write( "SCALARS " + _name + " double\n" )95  _file.write( "LOOKUP_TABLE default\n" )96  for i in range(0,_self.npoints):97   _file.write( str(_scalar.item(i)) + "\n" )98  _file.write( "\n" )99 def vtkVector(_self,_file,_name,_vec1,_vec2):100  _file.write( "VECTORS " + _name + " double\n" )101  for i in range(0,_self.npoints):102   _file.write( str(_vec1.item(i)) + " " + \103                str(_vec2.item(i)) + " 0.0\n" )104  _file.write( "\n" )105# def printMeshReport(_self):106#  """107#   Print mesh report for lineMesh and Mesh108#  """109#  print ""110#  print ""111#  print "|" + "-"*30 + " Mesh Report " + "-"*30 + "|"112#  print " "*5 + "number of 2D points (npoints):          " + \113#        str(_self.npoints)114#  print " "*5 + "number of triangles (nelem):          " + \115#        str(_self.nelem)116#--------------------------------------------------117#   print ""118#   for nb in range(0,_self.mesh.elemIdRegion.max()+1):119#    print " "*5 + "line (" + str(nb) + ")" 120#    print " "*5 + "  |length (averageLength):              " + \121#         str(_self.mesh.averageEdgeLength)122#-------------------------------------------------- 123#124#  print "|" + "-"*73 + "|"125#  print ""126#  print ""127class Quad1D:128 def __init__(_self,_x,_IEN,_npoints,_nelem,_scalar1,_scalar2,_scalar3,_vec1,_vec2):129  _self.x = _x130  _self.IEN = _IEN131  _self.npoints = _npoints132  _self.nelem = _nelem133  _self.scalar1 = _scalar1134  _self.scalar2 = _scalar2135  _self.scalar3 = _scalar3136  _self.vec1 = _vec1137  _self.vec2 = _vec2138 def create_dir(_self,_dir):139  _self.path = os.getcwd()140  # make result directory141  if not 'results' in os.listdir(_self.path):142   os.mkdir(_self.path + '/results')143  # make save directory144  _self.path = _self.path + '/results'145  if not _dir in os.listdir(_self.path):146   _self.dir = _dir147   os.mkdir(_self.path + '/' + _self.dir)148  else:149   _self.dir = _dir150  _self.path = _self.path + '/' + _self.dir151 def saveVTK(_self,_file):152  vtkFile = open(_self.path + '/' + _file + '.vtk', 'w')153  _self.vtkHeader(vtkFile)154  _self.vtkCoords(vtkFile)155  _self.vtkCellArray(vtkFile)156  _self.vtkCellType(vtkFile)157  _self.vtkScalarScalarHeader(vtkFile)158  _self.vtkVector(vtkFile,'vector', _self.vec1, _self.vec2)159  if _self.scalar1 is not None:160   _self.vtkScalar(vtkFile,"scalar1",_self.scalar1);161  162  if _self.scalar2 is not None:163   _self.vtkScalar(vtkFile,"scalar2",_self.scalar2);164  if _self.scalar3 is not None:165   _self.vtkScalar(vtkFile,"scalar3",_self.scalar3);166  vtkFile.close()167 def vtkHeader(_self,_file,_iter=None):168  _file.write( "# vtk DataFile Version 2.0\n" )169  _file.write( "1D Simulation Python\n" )170  _file.write( "ASCII\n" )171  _file.write( "DATASET UNSTRUCTURED_GRID\n" )172  _file.write( "FIELD FieldData 1\n" )173  _file.write( "NODES 1 2 int\n" )174  _file.write( str(_self.npoints) + " " + \175               str(_self.nelem) + "\n" )176  _file.write( "\n" )177 def vtkCoords(_self,_file):178  _file.write( "POINTS " + str(_self.npoints) + " double\n" )179  for i in range(0,_self.npoints):180   _file.write( str(_self.x[i][0]) + " 0.0" + " 0.0\n" )181  _file.write( "\n" )182 def vtkCellArray(_self,_file):183  _file.write( "CELLS " + str(_self.nelem) \184                        + " " + str(4*_self.nelem) + "\n" )185  for i in range(0,_self.nelem):186   _file.write( "3 " + str(_self.IEN[i][0]) + " " + \187                       str(_self.IEN[i][1]) + " " + \188                       str(_self.IEN[i][2]) + "\n" )189  _file.write( "\n" )190 def vtkCellType(_self,_file):191  _file.write( "CELL_TYPES " + str(_self.nelem) + "\n" )192  for i in range(0,_self.nelem):193   _file.write( "21 ")194   _file.write( "\n" )195 196  _file.write( "\n" )197   198 def vtkScalarHeader(_self,_file):199  _file.write( "POINT_DATA " + str(_self.npoints) + "\n" )200  _file.write( "\n" )201 def vtkScalarScalarHeader(_self,_file):202  _file.write( "POINT_DATA " + str(_self.npoints) + "\n" )203 def vtkScalar(_self,_file,_name,_scalar):204  _file.write( "SCALARS " + _name + " double\n" )205  _file.write( "LOOKUP_TABLE default\n" )206  for i in range(0,_self.npoints):207   _file.write( str(_scalar.item(i)) + "\n" )208  _file.write( "\n" )209 def vtkVector(_self,_file,_name,_vec1,_vec2):210  _file.write( "VECTORS " + _name + " double\n" )211  for i in range(0,_self.npoints):212   _file.write( str(_vec1.item(i)) + " " + \213                str(_vec2.item(i)) + " 0.0\n" )214  _file.write( "\n" )215# def printMeshReport(_self):216#  """217#   Print mesh report for lineMesh and Mesh218#  """219#  print ""220#  print ""221#  print "|" + "-"*30 + " Mesh Report " + "-"*30 + "|"222#  print " "*5 + "number of 2D points (npoints):          " + \223#        str(_self.npoints)224#  print " "*5 + "number of triangles (nelem):          " + \225#        str(_self.nelem)226#--------------------------------------------------227#   print ""228#   for nb in range(0,_self.mesh.elemIdRegion.max()+1):229#    print " "*5 + "line (" + str(nb) + ")" 230#    print " "*5 + "  |length (averageLength):              " + \231#         str(_self.mesh.averageEdgeLength)232#-------------------------------------------------- 233#234#  print "|" + "-"*73 + "|"235#  print ""236#  print ""237class Linear2D:238 def __init__(_self,_x,_y,_IEN,_npoints,_nelem,_scalar1,_scalar2,_scalar3,_vec1,_vec2):239  _self.x = _x240  _self.y = _y241  _self.IEN = _IEN242  _self.npoints = _npoints243  _self.nelem = _nelem244  _self.scalar1 = _scalar1245  _self.scalar2 = _scalar2246  _self.scalar3 = _scalar3247  _self.vec1 = _vec1248  _self.vec2 = _vec2249 def create_dir(_self,_dir):250  _self.path = os.getcwd()251  # make result directory252  if not 'results' in os.listdir(_self.path):253   os.mkdir(_self.path + '/results')254  # make save directory255  _self.path = _self.path + '/results'256  if not _dir in os.listdir(_self.path):257   _self.dir = _dir258   os.mkdir(_self.path + '/' + _self.dir)259  else:260   _self.dir = _dir261  _self.path = _self.path + '/' + _self.dir262 def saveVTK(_self,_file):263  vtkFile = open(_self.path + '/' + _file + '.vtk', 'w')264  _self.vtkHeader(vtkFile)265 266  _self.vtkCoords(vtkFile)267  _self.vtkCellArray(vtkFile)268  _self.vtkCellType(vtkFile)269  _self.vtkScalarScalarHeader(vtkFile)270  _self.vtkVector(vtkFile,'vector', _self.vec1, _self.vec2)271  if _self.scalar1 is not None:272   _self.vtkScalar(vtkFile,"scalar1",_self.scalar1);273  274  if _self.scalar2 is not None:275   _self.vtkScalar(vtkFile,"scalar2",_self.scalar2);276  if _self.scalar3 is not None:277   _self.vtkScalar(vtkFile,"scalar3",_self.scalar3);278  vtkFile.close()279 def vtkHeader(_self,_file,_iter=None):280  _file.write( "# vtk DataFile Version 2.0\n" )281  _file.write( "2D Simulation Python\n" )282  _file.write( "ASCII\n" )283  _file.write( "DATASET UNSTRUCTURED_GRID\n" )284  _file.write( "FIELD FieldData 1\n" )285  _file.write( "NODES 1 2 int\n" )286  _file.write( str(_self.npoints) + " " + \287               str(_self.nelem) + "\n" )288  _file.write( "\n" )289 def vtkCoords(_self,_file):290  _file.write( "POINTS " + str(_self.npoints) + " double\n" )291  for i in range(0,_self.npoints):292   _file.write( str(_self.x[i][0]) + " " + \293                str(_self.y[i][0]) + " 0.0\n" )294  _file.write( "\n" )295 def vtkCellArray(_self,_file):296  _file.write( "CELLS " + str(_self.nelem) \297                        + " " + str(4*_self.nelem) + "\n" )298  for i in range(0,_self.nelem):299   _file.write( "3 " + str(_self.IEN[i][0]) + " " + \300                       str(_self.IEN[i][1]) + " " + \301                       str(_self.IEN[i][2]) + "\n" )302  _file.write( "\n" )303 def vtkCellType(_self,_file):304  _file.write( "CELL_TYPES " + str(_self.nelem) + "\n" )305  for i in range(0,_self.nelem):306   _file.write( "5 ")307   _file.write( "\n" )308 309  _file.write( "\n" )310   311 def vtkScalarHeader(_self,_file):312  _file.write( "POINT_DATA " + str(_self.npoints) + "\n" )313  _file.write( "\n" )314 def vtkScalarScalarHeader(_self,_file):315  _file.write( "POINT_DATA " + str(_self.npoints) + "\n" )316 def vtkScalar(_self,_file,_name,_scalar):317  _file.write( "SCALARS " + _name + " double\n" )318  _file.write( "LOOKUP_TABLE default\n" )319  for i in range(0,_self.npoints):320   _file.write( str(_scalar.item(i)) + "\n" )321  _file.write( "\n" )322 def vtkVector(_self,_file,_name,_vec1,_vec2):323  _file.write( "VECTORS " + _name + " double\n" )324  for i in range(0,_self.npoints):325   _file.write( str(_vec1.item(i)) + " " + \326                str(_vec2.item(i)) + " 0.0\n" )327  _file.write( "\n" )328# def printMeshReport(_self):329#  """330#   Print mesh report for lineMesh and Mesh331#  """332#  print ""333#  print ""334#  print "|" + "-"*30 + " Mesh Report " + "-"*30 + "|"335#  print " "*5 + "number of 2D points (npoints):          " + \336#        str(_self.npoints)337#  print " "*5 + "number of triangles (nelem):          " + \338#        str(_self.nelem)339#--------------------------------------------------340#   print ""341#   for nb in range(0,_self.mesh.elemIdRegion.max()+1):342#    print " "*5 + "line (" + str(nb) + ")" 343#    print " "*5 + "  |length (averageLength):              " + \344#         str(_self.mesh.averageEdgeLength)345#-------------------------------------------------- 346#347#  print "|" + "-"*73 + "|"348#  print ""349#  print ""350class Mini2D:351 def __init__(_self,_x,_y,_IEN,_npoints,_nelem,_scalar1,_scalar2,_scalar3,_vec1,_vec2):352  _self.x = _x353  _self.y = _y354  _self.IEN = _IEN355  _self.npoints = _npoints356  _self.nelem = _nelem357  _self.scalar1 = _scalar1358  _self.scalar2 = _scalar2359  _self.scalar3 = _scalar3360  _self.vec1 = _vec1361  _self.vec2 = _vec2362 def create_dir(_self,_dir):363  _self.path = os.getcwd()364  # make result directory365  if not 'results' in os.listdir(_self.path):366   os.mkdir(_self.path + '/results')367  # make save directory368  _self.path = _self.path + '/results'369  if not _dir in os.listdir(_self.path):370   _self.dir = _dir371   os.mkdir(_self.path + '/' + _self.dir)372  else:373   _self.dir = _dir374  _self.path = _self.path + '/' + _self.dir375 def saveVTK(_self,_file):376  vtkFile = open(_self.path + '/' + _file + '.vtk', 'w')377  _self.vtkHeader(vtkFile)378  _self.vtkCoords(vtkFile)379  _self.vtkCellArray(vtkFile)380  _self.vtkCellType(vtkFile)381  _self.vtkScalarScalarHeader(vtkFile)382  _self.vtkVector(vtkFile,'vector', _self.vec1, _self.vec2)383  if _self.scalar1 is not None:384   _self.vtkScalar(vtkFile,"scalar1",_self.scalar1);385  386  if _self.scalar2 is not None:387   _self.vtkScalar(vtkFile,"scalar2",_self.scalar2);388  if _self.scalar3 is not None:389   _self.vtkScalar(vtkFile,"scalar3",_self.scalar3);390  vtkFile.close()391 def vtkHeader(_self,_file,_iter=None):392  _file.write( "# vtk DataFile Version 2.0\n" )393  _file.write( "2D Simulation Python\n" )394  _file.write( "ASCII\n" )395  _file.write( "DATASET UNSTRUCTURED_GRID\n" )396  _file.write( "FIELD FieldData 1\n" )397  _file.write( "NODES 1 2 int\n" )398  _file.write( str(_self.npoints) + " " + \399               str(_self.nelem) + "\n" )400  _file.write( "\n" )401 def vtkCoords(_self,_file):402  _file.write( "POINTS " + str(_self.npoints) + " double\n" )403  for i in range(0,_self.npoints):404   _file.write( str(_self.x[i][0]) + " " + \405                str(_self.y[i][0]) + " 0.0\n" )406  _file.write( "\n" )407 def vtkCellArray(_self,_file):408  _file.write( "CELLS " + str(_self.nelem) \409                        + " " + str(5*_self.nelem) + "\n" )410  for i in range(0,_self.nelem):411   _file.write( "4 " + str(_self.IEN[i][0]) + " " + \412                       str(_self.IEN[i][1]) + " " + \413                       str(_self.IEN[i][2]) + " " + \414                       str(_self.IEN[i][3]) + "\n" )415  _file.write( "\n" )416 def vtkCellType(_self,_file):417  _file.write( "CELL_TYPES " + str(_self.nelem) + "\n" )418  for i in range(0,_self.nelem):419   _file.write( "5 ")420   _file.write( "\n" )421 422  _file.write( "\n" )423   424 def vtkScalarHeader(_self,_file):425  _file.write( "POINT_DATA " + str(_self.npoints) + "\n" )426  _file.write( "\n" )427 def vtkScalarScalarHeader(_self,_file):428  _file.write( "POINT_DATA " + str(_self.npoints) + "\n" )429 def vtkScalar(_self,_file,_name,_scalar):430  _file.write( "SCALARS " + _name + " double\n" )431  _file.write( "LOOKUP_TABLE default\n" )432  for i in range(0,_self.npoints):433   _file.write( str(_scalar.item(i)) + "\n" )434  _file.write( "\n" )435 def vtkVector(_self,_file,_name,_vec1,_vec2):436  _file.write( "VECTORS " + _name + " double\n" )437  for i in range(0,_self.npoints):438   _file.write( str(_vec1.item(i)) + " " + \439                str(_vec2.item(i)) + " 0.0\n" )440  _file.write( "\n" )441# def printMeshReport(_self):442#  """443#   Print mesh report for lineMesh and Mesh444#  """445#  print ""446#  print ""447#  print "|" + "-"*30 + " Mesh Report " + "-"*30 + "|"448#  print " "*5 + "number of 2D points (npoints):          " + \449#        str(_self.npoints)450#  print " "*5 + "number of triangles (nelem):          " + \451#        str(_self.nelem)452#--------------------------------------------------453#   print ""454#   for nb in range(0,_self.mesh.elemIdRegion.max()+1):455#    print " "*5 + "line (" + str(nb) + ")" 456#    print " "*5 + "  |length (averageLength):              " + \457#         str(_self.mesh.averageEdgeLength)458#-------------------------------------------------- 459#460#  print "|" + "-"*73 + "|"461#  print ""462#  print ""463class Quad2D:464 def __init__(_self,_x,_y,_IEN,_npoints,_nelem,_scalar1,_scalar2,_scalar3,_vec1,_vec2):465  _self.x = _x466  _self.y = _y467  _self.IEN = _IEN468  _self.npoints = _npoints469  _self.nelem = _nelem470  _self.scalar1 = _scalar1471  _self.scalar2 = _scalar2472  _self.scalar3 = _scalar3473  _self.vec1 = _vec1474  _self.vec2 = _vec2475 def create_dir(_self,_dir):476  _self.path = os.getcwd()477  # make result directory478  if not 'results' in os.listdir(_self.path):479   os.mkdir(_self.path + '/results')480  # make save directory481  _self.path = _self.path + '/results'482  if not _dir in os.listdir(_self.path):483   _self.dir = _dir484   os.mkdir(_self.path + '/' + _self.dir)485  else:486   _self.dir = _dir487  _self.path = _self.path + '/' + _self.dir488 def saveVTK(_self,_file):489  vtkFile = open(_self.path + '/' + _file + '.vtk', 'w')490  _self.vtkHeader(vtkFile)491  _self.vtkCoords(vtkFile)492  _self.vtkCellArray(vtkFile)493  _self.vtkCellType(vtkFile)494  _self.vtkScalarScalarHeader(vtkFile)495  _self.vtkVector(vtkFile,'vector', _self.vec1, _self.vec2)496  if _self.scalar1 is not None:497   _self.vtkScalar(vtkFile,"scalar1",_self.scalar1);498  499  if _self.scalar2 is not None:500   _self.vtkScalar(vtkFile,"scalar2",_self.scalar2);501  if _self.scalar3 is not None:502   _self.vtkScalar(vtkFile,"scalar3",_self.scalar3);503  vtkFile.close()504 def vtkHeader(_self,_file,_iter=None):505  _file.write( "# vtk DataFile Version 2.0\n" )506  _file.write( "2D Simulation Python\n" )507  _file.write( "ASCII\n" )508  _file.write( "DATASET UNSTRUCTURED_GRID\n" )509  _file.write( "FIELD FieldData 1\n" )510  _file.write( "NODES 1 2 int\n" )511  _file.write( str(_self.npoints) + " " + \512               str(_self.nelem) + "\n" )513  _file.write( "\n" )514 def vtkCoords(_self,_file):515  _file.write( "POINTS " + str(_self.npoints) + " double\n" )516  for i in range(0,_self.npoints):517   _file.write( str(_self.x[i][0]) + " " + \518                str(_self.y[i][0]) + " 0.0\n" )519  _file.write( "\n" )520 def vtkCellArray(_self,_file):521  _file.write( "CELLS " + str(_self.nelem) \522                        + " " + str(7*_self.nelem) + "\n" )523  for i in range(0,_self.nelem):524   _file.write( "6 " + str(_self.IEN[i][0]) + " " + \525                       str(_self.IEN[i][1]) + " " + \526                       str(_self.IEN[i][2]) + " " + \527                       str(_self.IEN[i][3]) + " " + \528                       str(_self.IEN[i][4]) + " " + \529                       str(_self.IEN[i][5]) + "\n" )530  _file.write( "\n" )531 def vtkCellType(_self,_file):532  _file.write( "CELL_TYPES " + str(_self.nelem) + "\n" )533  for i in range(0,_self.nelem):534   _file.write( "22 ")535   _file.write( "\n" )536 537  _file.write( "\n" )538   539 def vtkScalarHeader(_self,_file):540  _file.write( "POINT_DATA " + str(_self.npoints) + "\n" )541  _file.write( "\n" )542 def vtkScalarScalarHeader(_self,_file):543  _file.write( "POINT_DATA " + str(_self.npoints) + "\n" )544 def vtkScalar(_self,_file,_name,_scalar):545  _file.write( "SCALARS " + _name + " double\n" )546  _file.write( "LOOKUP_TABLE default\n" )547  for i in range(0,_self.npoints):548   _file.write( str(_scalar.item(i)) + "\n" )549  _file.write( "\n" )550 def vtkVector(_self,_file,_name,_vec1,_vec2):551  _file.write( "VECTORS " + _name + " double\n" )552  for i in range(0,_self.npoints):553   _file.write( str(_vec1.item(i)) + " " + \554                str(_vec2.item(i)) + " 0.0\n" )555  _file.write( "\n" )556# def printMeshReport(_self):557#  """558#   Print mesh report for lineMesh and Mesh559#  """560#  print ""561#  print ""562#  print "|" + "-"*30 + " Mesh Report " + "-"*30 + "|"563#  print " "*5 + "number of 2D points (npoints):          " + \564#        str(_self.npoints)565#  print " "*5 + "number of triangles (nelem):          " + \566#        str(_self.nelem)567#--------------------------------------------------568#   print ""569#   for nb in range(0,_self.mesh.elemIdRegion.max()+1):570#    print " "*5 + "line (" + str(nb) + ")" 571#    print " "*5 + "  |length (averageLength):              " + \572#         str(_self.mesh.averageEdgeLength)573#-------------------------------------------------- 574#575#  print "|" + "-"*73 + "|"576#  print ""...test_file_completeness.py
Source:test_file_completeness.py  
1import os2import unittest3from packaging import version4from src.utils.general import get_app_version5from tests.utils import get_project_root, get_file_size6ROOT_DIR = get_project_root()7def is_dir_empty(path):8    return len(os.listdir(path)) == 09class TestDirectoryIntegrity(unittest.TestCase):10    def test_screenshots_dir_exists(self):11        _dir = ROOT_DIR.joinpath('screenshots')12        self.assertEqual(_dir.exists(), True)13        self.assertEqual(_dir.is_dir(), True)14        self.assertEqual(is_dir_empty(_dir), False)15    def test_zip_dir_exists(self):16        _dir = ROOT_DIR.joinpath('zip')17        self.assertEqual(_dir.exists(), True)18        self.assertEqual(_dir.is_dir(), True)19        self.assertEqual(is_dir_empty(_dir), False)20    def test_tools_dir_exists(self):21        _dir = ROOT_DIR.joinpath('tools')22        self.assertEqual(_dir.exists(), True)23        self.assertEqual(_dir.is_dir(), True)24        self.assertEqual(is_dir_empty(_dir), False)25    def test_assets_dir_exists(self):26        _dir = ROOT_DIR.joinpath('assets')27        self.assertEqual(_dir.exists(), True)28        self.assertEqual(_dir.is_dir(), True)29        self.assertEqual(is_dir_empty(_dir), False)30    def test_tests_dir_exists(self):31        _dir = ROOT_DIR.joinpath('tests')32        self.assertEqual(_dir.exists(), True)33        self.assertEqual(_dir.is_dir(), True)34        self.assertEqual(is_dir_empty(_dir), False)35    def test_src_dir_exists(self):36        _dir = ROOT_DIR.joinpath('src')37        self.assertEqual(_dir.exists(), True)38        self.assertEqual(_dir.is_dir(), True)39        self.assertEqual(is_dir_empty(_dir), False)40    def test_docs_dir_exists(self):41        _dir = ROOT_DIR.joinpath('docs')42        self.assertEqual(_dir.exists(), True)43        self.assertEqual(_dir.is_dir(), True)44        self.assertEqual(is_dir_empty(_dir), False)45    def test_pyinstaller_hooks_dir_exists(self):46        _dir = ROOT_DIR.joinpath('hooks')47        self.assertEqual(_dir.exists(), True)48        self.assertEqual(_dir.is_dir(), True)49        self.assertEqual(is_dir_empty(_dir), False)50class TestFileIntegrity(unittest.TestCase):51    def test_requirements_exists(self):52        _file = ROOT_DIR.joinpath('requirements.txt')53        self.assertEqual(_file.exists(), True)54        self.assertEqual(_file.is_dir(), False)55        self.assertNotEqual(get_file_size(_file), 0)56    def test_license_exists(self):57        _file = ROOT_DIR.joinpath('LICENSE')58        self.assertEqual(_file.exists(), True)59        self.assertEqual(_file.is_dir(), False)60        self.assertNotEqual(get_file_size(_file), 0)61    def test_readme_exists(self):62        _file = ROOT_DIR.joinpath('README.md')63        self.assertEqual(_file.exists(), True)64        self.assertEqual(_file.is_dir(), False)65        self.assertNotEqual(get_file_size(_file), 0)66    def test_win_build_exists(self):67        _file = ROOT_DIR.joinpath('win_build.bat')68        self.assertEqual(_file.exists(), True)69        self.assertEqual(_file.is_dir(), False)70        self.assertNotEqual(get_file_size(_file), 0)71    def test_linux_build_exists(self):72        _file = ROOT_DIR.joinpath('linux_build.sh')73        self.assertEqual(_file.exists(), True)74        self.assertEqual(_file.is_dir(), False)75        self.assertNotEqual(get_file_size(_file), 0)76    def test_disclaimer_exists(self):77        _file = ROOT_DIR.joinpath('DISCLAIMER.md')78        self.assertEqual(_file.exists(), True)79        self.assertEqual(_file.is_dir(), False)80        self.assertNotEqual(get_file_size(_file), 0)81    def test_version_file_valid(self):82        _file = ROOT_DIR.joinpath('version')83        self.assertEqual(_file.exists(), True)84        self.assertEqual(_file.is_dir(), False)85        self.assertNotEqual(get_file_size(_file), 0)86        with open(_file, 'r') as f:87            ver = f.read()88        self.assertEqual(ver, get_app_version())89        self.assertEqual(type(version.parse(ver)), version.Version)90    def test_banner_valid(self):91        _file = ROOT_DIR.joinpath('assets', 'banner.png')92        self.assertEqual(_file.exists(), True)93        self.assertNotEqual(get_file_size(_file), 0)94    def test_code_of_conduct_valid(self):95        _file = ROOT_DIR.joinpath('.github', 'CODE_OF_CONDUCT.md')96        self.assertEqual(_file.exists(), True)97        self.assertNotEqual(get_file_size(_file), 0)98    def test_pull_request_template_valid(self):99        _file = ROOT_DIR.joinpath('.github', 'PULL_REQUEST_TEMPLATE.md')100        self.assertEqual(_file.exists(), True)101        self.assertNotEqual(get_file_size(_file), 0)102    def test_funding_valid(self):103        _file = ROOT_DIR.joinpath('.github', 'FUNDING.yml')104        self.assertEqual(_file.exists(), True)105        self.assertNotEqual(get_file_size(_file), 0)106    def test_workflows_valid(self):107        _file = ROOT_DIR.joinpath('.github', 'workflows', 'run-pytest.yml')108        self.assertEqual(_file.exists(), True)109        self.assertNotEqual(get_file_size(_file), 0)110        _file = ROOT_DIR.joinpath('.github', 'workflows', 'wgv-pyinstaller.yml')111        self.assertEqual(_file.exists(), True)112        self.assertNotEqual(get_file_size(_file), 0)113        _file = ROOT_DIR.joinpath('.github', 'workflows', 'labeler.yml')114        self.assertEqual(_file.exists(), True)115        self.assertNotEqual(get_file_size(_file), 0)116    def test_issue_template_valid(self):117        _file = ROOT_DIR.joinpath('.github', 'ISSUE_TEMPLATE', 'bug_report.md')118        self.assertEqual(_file.exists(), True)119        self.assertNotEqual(get_file_size(_file), 0)120        _file = ROOT_DIR.joinpath('.github', 'ISSUE_TEMPLATE', 'feature_request.md')121        self.assertEqual(_file.exists(), True)122        self.assertNotEqual(get_file_size(_file), 0)123if __name__ == '__main__':...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
