leopoldo-zugasti
3 年前
当前提交
991b1a9f
共有 3 个文件被更改,包括 609 次插入 和 474 次删除
-
6com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs
-
998com.unity.perception/Editor/Visualizer/VisualizerInstaller.cs
-
79com.unity.perception/Editor/Visualizer/PipAPI.cs
998
com.unity.perception/Editor/Visualizer/VisualizerInstaller.cs
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Net.Http; |
|||
using System.Net.Http.Headers; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Linq; |
|||
using Unity.Simulation.Client; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.Perception.Visualizer |
|||
{ |
|||
static class PipAPI |
|||
{ |
|||
static readonly HttpClient k_HttpClient; |
|||
static string s_PypiServer = "https://pypi.org"; |
|||
static string s_PackageName = "unity-cv-datasetvisualizer"; |
|||
|
|||
static PipAPI() |
|||
{ |
|||
k_HttpClient = new HttpClient(); |
|||
} |
|||
|
|||
static internal async Task<string> GetLatestVersionNumber() |
|||
{ |
|||
var requestUri = new Uri($"{s_PypiServer}/pypi/{s_PackageName}/json?Accept=application/json"); |
|||
try |
|||
{ |
|||
var httpResponse = await k_HttpClient.GetAsync(requestUri); |
|||
if (httpResponse.IsSuccessStatusCode) |
|||
{ |
|||
var responseString = httpResponse.Content.ReadAsStringAsync().Result; |
|||
dynamic responseJson = JsonConvert.DeserializeObject(responseString); |
|||
return responseJson.info.version; |
|||
} |
|||
else |
|||
{ |
|||
HandleApiErrors(httpResponse); |
|||
} |
|||
} |
|||
catch (HttpRequestException e) |
|||
{ |
|||
Debug.LogException(e); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
static void HandleApiErrors(HttpResponseMessage responseMessage) |
|||
{ |
|||
Debug.LogError("A request to PyPI.org did not successfully complete: " + responseMessage.ReasonPhrase); |
|||
} |
|||
|
|||
static internal int compareVersions(string version1, string version2) |
|||
{ |
|||
string[] split1 = version1.Split('.'); |
|||
string[] split2 = version2.Split('.'); |
|||
|
|||
if(split1.Length != split2.Length) |
|||
{ |
|||
throw new ArgumentException($"Can't compare two versions that do not have the same format: {version1} & {version2}"); |
|||
} |
|||
|
|||
for(int i = 0; i < split1.Length; i++) |
|||
{ |
|||
int compare = Int32.Parse(split1[i]) - Int32.Parse(split2[i]); |
|||
if (compare != 0) |
|||
{ |
|||
return compare; |
|||
} |
|||
} |
|||
return 0; |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue