Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17194 for misc/tools


Ignore:
Timestamp:
08/07/19 14:44:13 (5 years ago)
Author:
mkommend
Message:

#2829: Updated HiveDrain to .Net version 4.6.1 and added handling of invalid characters in filenames.

Location:
misc/tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • misc/tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain.csproj

    r15921 r17194  
    11<?xml version="1.0" encoding="utf-8"?>
    2 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     2<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    33  <PropertyGroup>
    44    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     
    1111    <RootNamespace>HiveDrain</RootNamespace>
    1212    <AssemblyName>HeuristicLab.HiveDrain</AssemblyName>
    13     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     13    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    1414    <TargetFrameworkProfile>
    1515    </TargetFrameworkProfile>
  • misc/tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobDownloader.cs

    r15347 r17194  
    2323using System.Collections.Generic;
    2424using System.IO;
     25using System.Linq;
    2526using System.Threading;
    2627using HeuristicLab.Clients.Hive;
     
    5152      Semaphore limitSemaphore = new Semaphore(HeuristicLabHiveDrainApplication.MaxParallelDownloads, HeuristicLabHiveDrainApplication.MaxParallelDownloads);
    5253
     54      var invalidChars = Path.GetInvalidFileNameChars();
     55
    5356      foreach (Job j in jobsLoaded) {
    5457        if (string.IsNullOrEmpty(NamePattern) || j.Name.Contains(NamePattern)) {
    55           string jobPath = Path.Combine(RootLocation, String.Format("{0} - {1}", j.Name, j.Id));
    5658          log.LogMessage(String.Format("\"{0}\": {1}", j.Name, j.Id));
     59
     60
     61          var jobName = j.Name;
     62          //handle invalid characters in fileNames
     63          if (invalidChars.Any(c => jobName.Contains(c))) {
     64            log.LogMessage("Job name contains characters that cannot be used as filename. Invalid characters are replaced with '_'.");
     65            foreach (var c in invalidChars) {
     66              jobName = jobName.Replace(c, '_');
     67            }
     68          }
     69
     70          string jobPath = Path.Combine(RootLocation, String.Format("{0} - {1}", jobName, j.Id));
     71
    5772
    5873          if (OneFile) {
    5974            JobTaskOneFileDownloader taskDownloader = new JobTaskOneFileDownloader(jobPath, j, limitSemaphore, log);
    6075            taskDownloader.Start();
    61           } else {
     76          }
     77          else {
    6278            JobTaskDownloader taskDownloader = new JobTaskDownloader(jobPath, j, limitSemaphore, log);
    6379            taskDownloader.Start();
    6480          }
    65         } else {
     81        }
     82        else {
    6683          log.LogMessage(String.Format("\"{0}\": {1} ---> ignored", j.Name, j.Id));
    6784        }
  • misc/tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobTaskOneFileDownloader.cs

    r15494 r17194  
    3333namespace HeuristicLab.HiveDrain {
    3434  public class JobTaskOneFileDownloader {
    35     public String RootLocation { get; set; }
     35    public string RootLocation { get; set; }
    3636
    3737    public Job ParentJob { get; set; }
     
    3939    private ILog log;
    4040
    41     private RunCollection results = new RunCollection();
    4241
    4342    private static ConcurrentTaskDownloader<ItemTask> downloader =
    4443        new ConcurrentTaskDownloader<ItemTask>(HeuristicLabHiveDrainApplication.MaxParallelDownloads, HeuristicLabHiveDrainApplication.MaxParallelDownloads);
    45 
    46     private static int jobCount = 0;
    47 
    48     private static bool endReached = false;
    4944
    5045    private ManualResetEvent allJobsFinished = new ManualResetEvent(false);
     
    6863
    6964    public void Start() {
    70       results = new RunCollection();
    7165
    7266      var allTasks = HiveServiceLocator.Instance.CallHiveService(s => s.GetLightweightJobTasksWithoutStateLog(ParentJob.Id));
Note: See TracChangeset for help on using the changeset viewer.