Log in

View Full Version : [solved] module 'sys' has no attribute 'argv'


shader
29th July 2016, 17:29
In order to develop scripts faster, I just take small parts of the video first. My idea is to use a switch, which is overwritten when running the final batch file via command arguments (see simplified script below).

import os, sys
import vapoursynth as vs

LongVideo = False

if len(sys.argv):
for arg in sys.argv:
if arg == "long=True":
LongVideo = True

print("\nLongVideo... {}".format("yes" if LongVideo else "no"), flush=True, file=sys.stderr)

core = vs.get_core()

if LongVideo == True:
video = core.std.BlankClip(length=100)
else:
video = core.std.BlankClip(length=1)

video.set_output()
enable_v210 = True


vspipe --arg full=True --y4m vs_test_args.py - | x264 --demuxer y4m - --output ..\arg_test.mp4

Unfortunatelly the usually known sys.argv do not work (if len(sys.argv): --> AttributeError: module 'sys' has no attribute 'argv').

Does anybody know the solution?

Thanks!

Myrsloik
29th July 2016, 18:18
vspipe --arg full=True --y4m vs_test_args.py




if (full == 'True')
do_something()
..

Using --arg in vspipe will simply set a global variable with that name to the specified value. And the value is always interpreted as a utf8 string (bytes) object.

shader
29th July 2016, 20:07
:thanks::thanks::thanks:

In order to work with vspipe and vs-editor I had to do a small adaption, which was really easy because of your explaination!!!


if 'full' in globals() and full == b'True':
FullVideo = True