ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Evidox/MCP3_Initiator.py
Revision: 633
Committed: Wed Mar 28 13:54:39 2018 UTC (8 years ago) by nino.borges
Content type: text/x-python
File size: 4515 byte(s)
Log Message:
A folder for my Evidox programs

File Contents

# User Rev Content
1 nino.borges 633 """
2     MCP3_Initiator.py
3    
4     Created by
5     Emanuel Borges
6     08.02.2017
7    
8     Methods for the inital setup for things like creating the casefolder web shortcuts. Maybe this will turn into a tron verifer...
9    
10     """
11    
12     import os
13     from win32com.client import Dispatch
14    
15    
16     def CreateCaseFolderLNK(caseFolderPath, wShell):
17     """Creates a single shortcut for the case-folder"""
18     if os.path.exists(os.path.join(caseFolderPath,r'_lib')):
19     pass
20     else:
21     print "creating _lib dir..."
22     os.mkdir(os.path.join(caseFolderPath,r'_lib'))
23     wLnk = wShell.CreateShortCut(os.path.join(caseFolderPath,r'_lib\case-folder.lnk'))
24     wLnk.Targetpath = caseFolderPath
25     wLnk.WorkingDirectory = caseFolderPath
26     #wLnk.IconLocation = icon
27     wLnk.save()
28     print "shortcut created."
29    
30     def CreateFileCabinetLNK(caseFolderPath, wShell):
31     """Creates a single shortcut for the file-cabinet"""
32     if os.path.exists(os.path.join(caseFolderPath,r'_lib')):
33     pass
34     else:
35     print "creating _lib dir..."
36     os.mkdir(os.path.join(caseFolderPath,r'_lib'))
37     wLnk = wShell.CreateShortCut(os.path.join(caseFolderPath,r'_lib\file-cabinet.lnk'))
38     wLnk.Targetpath = os.path.join(caseFolderPath,"File_Cabinet")
39     wLnk.WorkingDirectory = os.path.join(caseFolderPath,"File_Cabinet")
40     #wLnk.IconLocation = icon
41     wLnk.save()
42     print "shortcut created."
43    
44     def CreateOpperatingDocLNK(caseFolderPath, wShell):
45     """Creates a single shortcut for the Opperating Docs Folder"""
46     if os.path.exists(os.path.join(caseFolderPath,r'_lib')):
47     pass
48     else:
49     print "creating _lib dir..."
50     os.mkdir(os.path.join(caseFolderPath,r'_lib'))
51     wLnk = wShell.CreateShortCut(os.path.join(caseFolderPath,r'_lib\op-docs-folder.lnk'))
52     wLnk.Targetpath = os.path.join(caseFolderPath,"Operating Documents")
53     wLnk.WorkingDirectory = os.path.join(caseFolderPath,"Operating Documents")
54     #wLnk.IconLocation = icon
55     wLnk.save()
56     print "shortcut created."
57    
58     def ClientListFromDir(myCasesPath):
59     """Takes a dir and returns only the client foldernames as a list"""
60     rawList = os.listdir(myCasesPath)
61     skipList = ['_client_template',]
62     clientList = []
63     for i in rawList:
64     if os.path.isdir(os.path.join(myCasesPath,i)):
65     if i in skipList:
66     pass
67     else:
68     clientList.append(i)
69     return clientList
70    
71     def CreateCaseFolderLNKs(myCasesPath, wShell):
72     """Go through the cases and verify that each has a case-folder lnk and a file-cabinet lnk. If not, create it."""
73     clientList = ClientListFromDir(myCasesPath)
74     for client in clientList:
75     print "Now checking client %s ..."% client
76     for case in os.listdir(os.path.join(myCasesPath,client)):
77     ## check to make sure the case is actually a case and not just a loose file
78     if os.path.isdir(os.path.join(os.path.join(myCasesPath,client),case)):
79     print "Checking case %s ..."% case
80     ## verify case-folder lnk
81     if os.path.exists(os.path.join(os.path.join(os.path.join(myCasesPath,client),case),r'_lib\case-folder.lnk')):
82     print "exists in %s\n"%case
83     else:
84     print "doesnt exist in %s. Creating..."%case
85     CreateCaseFolderLNK(os.path.join(os.path.join(myCasesPath,client),case), wShell)
86     ## verify file-cabinet lnk
87     if os.path.exists(os.path.join(os.path.join(os.path.join(myCasesPath,client),case),r'_lib\file-cabinet.lnk')):
88     print "exists in %s\n"%case
89     else:
90     print "doesnt exist in %s. Creating..."%case
91     CreateFileCabinetLNK(os.path.join(os.path.join(myCasesPath,client),case), wShell)
92     ## verify OppDoc lnk
93     if os.path.exists(os.path.join(os.path.join(os.path.join(myCasesPath,client),case),r'_lib\op-docs-folder.lnk')):
94     print "exists in %s\n"%case
95     else:
96     print "doesnt exist in %s. Creating..."%case
97     CreateOpperatingDocLNK(os.path.join(os.path.join(myCasesPath,client),case), wShell)
98    
99    
100    
101     if __name__ == '__main__':
102     myCasesPath = r"L:\__People\Emanuel\MyCases"
103     wShell = Dispatch('WScript.Shell')
104    
105    
106     print "Checking for case-folder links..."
107     CreateCaseFolderLNKs(myCasesPath, wShell)