This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #https://stackoverflow.com/a/57084403 | |
| import io | |
| import time | |
| import subprocess | |
| import sys | |
| filename = 'test.log' | |
| with io.open(filename, 'wb') as writer, io.open(filename, 'rb', 1) as reader: | |
| process = subprocess.Popen(command, stdout=writer) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import threading | |
| import os | |
| import subprocess | |
| logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO) | |
| class LogPipe(threading.Thread): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace System.Runtime.CompilerServices { | |
| sealed class CallerMemberNameAttribute : Attribute { } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.IO; | |
| using System.Text; | |
| using System.Threading; | |
| namespace Clearcove.Logging | |
| { | |
| public sealed class Logger | |
| { | |
| #region Log File Writing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Net.Sockets; | |
| using System.Net; | |
| using System.IO; | |
| using System.Threading; | |
| using System.Windows.Forms; | |
| using Westwind.Utilities; | |
| namespace Westwind.WebConnection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void split(const string& s, vector<string>& tokens, const string& delimiters = " ") | |
| { | |
| string::size_type lastPos = s.find_first_not_of(delimiters, 0); | |
| string::size_type pos = s.find_first_of(delimiters, lastPos); | |
| while (string::npos != pos || string::npos != lastPos) { | |
| tokens.push_back(s.substr(lastPos, pos - lastPos));//use emplace_back after C++11 | |
| lastPos = s.find_first_not_of(delimiters, pos); | |
| pos = s.find_first_of(delimiters, lastPos); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| worksheet.TrimLastEmptyRows(); | |
| public static void TrimLastEmptyRows(this ExcelWorksheet worksheet) | |
| { | |
| while (worksheet.IsLastRowEmpty()) | |
| worksheet.DeleteRow(worksheet.Dimension.End.Row); | |
| } | |
| public static bool IsLastRowEmpty(this ExcelWorksheet worksheet) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void SendACommandToAutoCAD(string command) | |
| { | |
| MgdAcDocument doc = MgdApplication.DocumentManager.MdiActiveDocument; | |
| if(doc == null) | |
| { | |
| MessageBox.Show("当前无活动文档,请新建或切换至活动文档后再执行命令", "无法获取活动文档", MessageBoxButtons.OK, MessageBoxIcon.Stop); | |
| return; | |
| } | |
| // 根据是否有命令运行决定esc的数量 | |
| string esc = ""; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class RadioGroupBox : GroupBox | |
| { | |
| public event EventHandler SelectedChanged = delegate { }; | |
| int _selected; | |
| public int Selected | |
| { | |
| get | |
| { | |
| return _selected; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static bool IsInDesignMode() | |
| { | |
| if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) | |
| return true; | |
| if (Process.GetCurrentProcess().ProcessName == "devenv") return true; | |
| return false; | |
| } |
NewerOlder