|
5 | 5 | import pprint |
6 | 6 | import random |
7 | 7 | import time |
| 8 | +from pathlib import Path |
8 | 9 |
|
9 | 10 | from ..sync.resolver import TemplateResolver |
10 | 11 |
|
@@ -142,8 +143,8 @@ def asset_name(self): |
142 | 143 | def root_path(self): |
143 | 144 | rp = self.asset_item.get('root_path') |
144 | 145 | if self.entity.get('type') in ["PublishedFile"]: |
145 | | - # TODO: this needs to become dynamic |
146 | | - rp = "B:/" + self.entity.get('path_cache') |
| 146 | + # Add the drive letter or root from the project_path |
| 147 | + rp = os.path.join(Path(self.app.sgtk.project_path).anchor.replace("\\","/"), self.entity.get('path_cache')) |
147 | 148 | return rp |
148 | 149 |
|
149 | 150 | @property |
@@ -185,26 +186,27 @@ def get_perforce_sync_dry_reponse(self): |
185 | 186 | arguments = ["-n"] |
186 | 187 | if self.force_sync: |
187 | 188 | arguments.append("-f") |
188 | | - sync_response = self.p4.run("sync", arguments, "{}#head".format(self.root_path)) |
189 | | - |
190 | | - |
191 | | - if not sync_response: |
| 189 | + try: |
| 190 | + sync_response = self.p4.run("sync", arguments, "{}#head".format(self.root_path)) |
| 191 | + if not sync_response: |
| 192 | + self._status = "Syncd" |
| 193 | + self._icon = "success" |
| 194 | + self._detail = "Nothing new to sync for [{}]".format(self.root_path) |
| 195 | + else: |
| 196 | + # if the response from p4 has items... make UI elements for them |
| 197 | + self._items_to_sync = [i for i in sync_response if type(i) != str] |
| 198 | + self._status = "{} items to Sync".format(len(self._items_to_sync)) |
| 199 | + self._icon = "load" |
| 200 | + self._detail = self.root_path |
| 201 | + except Exception as e: |
| 202 | + self.log_error(f"Sync Response is - {e}") |
192 | 203 | self._status = "Not In Depot" |
193 | 204 | self._icon = "error" |
194 | | - self._detail = "Nothing in depot resolves [{}]".format(self.root_path) |
| 205 | + self._detail = "Nothing in depot resolves [{}]".format(self.root_path) |
195 | 206 |
|
196 | | - elif len(sync_response) is 1 and type(sync_response[0]) is str: |
197 | | - self._status = "Syncd" |
198 | | - self._icon = "success" |
199 | | - self._detail = "Nothing new to sync for [{}]".format(self.root_path) |
200 | | - else: |
201 | | - # if the response from p4 has items... make UI elements for them |
202 | | - self._items_to_sync = [i for i in sync_response if type(i) != str] |
203 | | - self._status = "{} items to Sync".format(len(self._items_to_sync)) |
204 | | - self._icon = "load" |
205 | | - self._detail = self.root_path |
206 | 207 | if self.entity.get('type') in ['PublishedFile']: |
207 | | - self._items_to_sync = [{"clientFile" : "B:/" + self.entity.get('path_cache')}] |
| 208 | + project_root = Path(self.app.sgtk.project_path).anchor.replace("\\","/") |
| 209 | + self._items_to_sync = [{"clientFile" : os.path.join(project_root, self.entity.get('path_cache'))}] |
208 | 210 | self._status = "Exact Path" |
209 | 211 | self._detail = "Exact path specified: [{}]".format(self.root_path) |
210 | 212 | self._icon = "load" |
|
0 commit comments