0

This is my first time making a question. I'm working in an application to copy certain information (from my PC) into 2 UBS's Drives at the same time, also, I'd to link a ProgressBar to each process, so everyone can see the progress of the copy.

Questions

  1. How I can start the two "copy process" at the same time and not sequentially.

  2. How I can add the Progressbar to each "copy process."

Thanks in advance.. really appreciate your help...!!!

Please see below my code:

import os
import time
import easygui
import sys
import glob
import shutil
from subprocess import check_output
import win32api
from setuptools import setup, find_packages
import progressbar
import subprocess 

Device_E = "E:"  ##(USB 1)
Device_F = "F:"  ##(USB 2)

##Making sure USB is plugged
USB_E = os.path.isdir(Device_E)
if USB_E == True:
    Status = 'Pass'
else:
    if USB_E == False:
        Status = 'Fail'
        ynbox = easygui.ynbox(msg='USB  E  Drive  Not  Found… Shall  I  continue ?', choices=('YES','NO'))
    if ynbox == 1:
        pass
    else:
        sys.exit()
if Status == 'Pass':
    check_output("format E: /Y/Q", shell=True)
    os.chdir(Source_Files)
    check_output("xcopy *.* e:\ /j/y/e/v", shell=True)### Need to add the processBar to this task

USB_F = os.path.isdir(Device_F)
if USB_F == True:
    Status = 'Pass'
else:
    if USB_F == False:
        Status = 'Fail'
        ynbox = easygui.ynbox(msg='USB  F  Drive  Not  Found… Shall  I  continue ?', choices=('YES','NO'))
    if ynbox == 1:
        pass
    else:
        sys.exit()
if Status == 'Pass':
    check_output("format F: /Y/Q", shell=True)
    os.chdir(Source_Files)
    check_output("xcopy *.* F:\ /j/y/e/v", shell=True)
F Casian
  • 93
  • 1
  • 11
  • First up... Why use the command line tools for copying? Every language has equivalent functions built-in (see [shutil](https://docs.python.org/2/library/shutil.html). It's also hard to read progress from a shell. You have to do lots of parsing and sometimes the info just isn't there. Instead, [Read the directory structure yourself](http://stackoverflow.com/questions/2212643/python-recursive-folder-read), then you'll know how many files there are and how many you've copied. Finally, use multiple [threads](https://docs.python.org/2/library/threading.html) so you can do the work in parallel – Basic Sep 22 '16 at 00:47
  • Thank you, I have solved my problem, now I have a new problem, when I run my script in the background a DOS window show up showing some progress and activity on going.... (shell) how I can insert that window into a Tkinter Frame? – F Casian Oct 10 '16 at 21:17
  • It's possible to hide the window and capture the output but please ask that as a new question. Better yet, search stack overflow because it's a solved problem and the answer is already floating around. I'd start with googling `python hide console window and capture output`. The first result for me was http://stackoverflow.com/questions/7006238/how-do-i-hide-the-console-when-i-use-os-system-or-subprocess-call – Basic Oct 10 '16 at 21:20

0 Answers0