Yup, I agree.
It looks like ffmpeg is using about 1/3 of the processing power, but this is likely intentional, because if it froze your computer you’d be pissed.
Yup, I agree.
It looks like ffmpeg is using about 1/3 of the processing power, but this is likely intentional, because if it froze your computer you’d be pissed.
nice catch!
I constantly switch between Js and python, and cant remember the differences lol
yeah, the --help
generation is a very convenient part of the libs.
I just wrote this to demonstrate the simplest possible answer.
programming in a nutshell
you have a really simple use-case, so you probably don’t need and argument parsing lib, which I would normally recommend…
You can just iterate through the arguments array and categorize them by type, then add them to the appropriate collection to be handled later.
Something like this:
ids = []
urls = []
csvs = []
for arg in sys.argv:
if arg.startswith('http'):
urls.push(arg)
else if arg.endswith('.csv'):
csvs.push(arg)
else:
ids.push(arg)
Most screenshot tools allow you to pass a name as an argument, so you could make a shell script to generate the name you want then call the screenshotting tool with the appropriate name. Also, consider using flameshot
Have you tested the throughput of dict.manager
?
If you need big scale, there is always redis.
Typically each project would have unit-tests that cover their own different edge cases, and the one that imports the other would have 1 end-to-end test that covers both functionality but doesn’t explore all of the edge cases.
def convert_video_progress_bar(self, manager, cmd):
name = self.path.rsplit(os.path.sep, 1)[-1]
# Run ffmpeg
proc = expect.spawn(cmd, encoding='utf-8')
pbar = None
try:
# extract the total number of frames
proc.expect(pattern_duration)
total = sum(map(lambda x: float(
x[1])*60**x[0], enumerate(reversed(proc.match.groups()[0].strip().split(':')))))
cont = 0
# keeps track of the progress to show it to the user
pbar = manager.counter(
total=100,
desc=name,
unit='%',
bar_format=BAR_FMT,
counter_format=COUNTER_FMT,
leave=False
)
# infinite loop
while True:
# look for a progress indicator, and extract the frame count
proc.expect(pattern_progress)
progress = sum(map(lambda x: float(
x[1])*60**x[0], enumerate(reversed(proc.match.groups()[0].strip().split(':')))))
# compute the percentage complete
percent = progress/total*100
# update the counter, to show the user
pbar.update(percent-cont)
cont = percent
# because of the infinite loop,
# `proc.expect` will throw an error once ffmpeg has completed.
# catch that error, and clean things up
except expect.EOF:
traceback.print_exc()
finally:
if pbar is not None:
pbar.close()
proc.expect(expect.EOF)
res = proc.before
res += proc.read()
# check to see if ffmpeg threw and error
exitstatus = proc.wait()
if exitstatus:
raise ffmpeg.Error('ffmpeg', '', res)
It would be helpful to link the full source like this
It looks like you’re using an older version of the code, so its hard to tell whats happening exactly. can you link it please?
The code is pretty much entirely just using the pexpect
library, so you’d need to familiarize yourself with that first. Read the API Overview section of the docs.
Also, a good way of figuring out how code works, is to print()
out the variables youre curious about.
I see.
res += "4 " + name
The problem here is you’re doing <List> += <str>
Changing it to: res.append('4 ' + name)
fixes it
It’s hard to understand what you’re trying to do here…
I would recommend stripping the problem down to a couple lines and explaining what you want and why your code doesn’t work.
If you’re trying to extract information from a string regular expressions are the way to go. You should probably add more to the regexp to capture the name and the percentage, like so:
re.match(r'(.*) \(([0-9]*)%\)', s).groups()
I think this is as close as you’re going to get
xargs apt-get install --ignore-missing < my_package_list.txt
sorry, I misread and thought he was asking trying to run “visual studio” or something lol
It’s not advised to run apps with sudo.
I created a script for vim that will let me save with sudo, so I just need the password when saving. I would recommend looking for a similar solution.
I would just ask it in the js & webdev community =]