Mac OS中SVN工具Versions日期重置脚本

简介: Versions是一个Mac OS下挺棒的SVN工具,不过有日期限制。网上有人提供了将Versions的使用日期重置的脚本,这个脚本有些值得学习的地方。

Versions是一个Mac OS下挺棒的SVN工具,不过有日期限制。网上有人提供了将Versions的使用日期重置的脚本,这个脚本有些值得学习的地方。贴出来做个记录。

 

#!/usr/bin/env python

import os, sys, re, plistlib, subprocess, re, time



userdir = os.path.expanduser('~')
prefdir = os.path.join(userdir, 'Library/Preferences')

pfile_a = os.path.join(prefdir,'com.madebysofa.Versions.plist')
pfile_b = 'com.picodev.Versions.plist'

hfile_a = '.CF89AA64'
hfile_b = '.FB64CF89'

globalprefs = os.path.join(prefdir, '.GlobalPreferences.plist')


def convert_plist_to_xml(plist_path):
	cmdline = '/usr/bin/plutil -convert xml1 "%s"' % plist_path
	os.system(cmdline)

def isVersionsRunning():
	p = subprocess.Popen(['ps','-Ac'],stdout=subprocess.PIPE)
	output = p.stdout.read()
	apps_re = re.search('^([0-9]+).*Versions$', output, re.M)
	if apps_re:
		return int(apps_re.group(1))
	else:
		return False

def killRunningVersions():	
	pid = isVersionsRunning()
	if pid:
		sys.stdout.write('Stopping currently running Versions...\n')
		os.system('kill %d' % pid)
	while isVersionsRunning():
		time.sleep(0.1)
		
def relaunchVersions():
	os.system('open -a /Applications/Versions.app')


if __name__ == '__main__':
	
	killRunningVersions()
	
	pfile_a_path = os.path.join(prefdir, pfile_a)
	pfile_b_path = os.path.join(prefdir, pfile_b)
	
	# --1) Start by deleting the hidden files.
	hfile_a1 = os.path.join(userdir, hfile_a)
	if os.path.exists(hfile_a1):
		print 'Removing "%s"'%hfile_a1
		os.remove(hfile_a1)
		
	hfile_b1 = os.path.join(os.path.join(userdir, 'Library/'), hfile_b)
	if os.path.exists(hfile_b1):
		print 'Removing "%s"'%hfile_b1
		os.remove(hfile_b1)
	
	# -- 2) Now, delete the expiry token from the globalprefs file...
	if os.path.exists(globalprefs):
		convert_plist_to_xml(globalprefs)
		pl = plistlib.readPlist(globalprefs)
		if 'com.madebysofa.Versions.ezsRequiredToken' in pl.keys():
			sys.stdout.write('Removing expiry token from .Globalprefs...\n')
			del pl['com.madebysofa.Versions.ezsRequiredToken']
			plistlib.writePlist(pl, globalprefs)
			
	# -- 2) Make sure that the "FirstRunDate" is also removed...
	if os.path.exists(pfile_a):
		convert_plist_to_xml(pfile_a)
		pl = plistlib.readPlist(pfile_a)
		if 'FirstRunDate' in pl.keys():
			sys.stdout.write('Removing FirstRunDate from "%s"\n' % pfile_a)
			del pl['FirstRunDate']
		if 'EZSBookmarksSelectionMask' in pl.keys():
			sys.stdout.write('Removing EZSBookmarksSelectionMask from "%s"' % pfile_a)
			del pl['EZSBookmarksSelectionMask']
			plistlib.writePlist(pl, pfile_a)
			
			
	sys.stdout.write('Launching Versions....')
	relaunchVersions()
	
	



 

目录
相关文章
|
开发工具 git iOS开发
Mac 安装软件包管理工具Homebrew
Mac 安装软件包管理工具Homebrew
|
5月前
|
安全 Linux iOS开发
SonarQube Server 2025 Release 5 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
SonarQube Server 2025 Release 5 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
279 0
SonarQube Server 2025 Release 5 (macOS, Linux, Windows) - 代码质量、安全与静态分析工具
|
10月前
|
Web App开发 安全 iOS开发
基于PyCharm与Mac系统的Chrome历史记录清理工具开发实战
《基于PyCharm与Mac系统的Chrome历史记录清理工具开发实战》详细解析了如何在macOS下通过Python脚本自动化清理Chrome浏览器的历史记录。文章以`clear_chrome_history.py`为例,结合PyCharm开发环境,深入讲解技术实现。内容涵盖进程检测、文件清理、虚拟环境配置及断点调试技巧,并提供安全增强与跨平台适配建议。该工具不仅保障个人隐私,还适用于自动化运维场景,具备较高实用价值。
345 0
|
7月前
|
数据安全/隐私保护 网络架构
在线MAC地址生成工具
免费在线生成随机MAC地址,支持多种格式(冒号、连字符、点、无分隔)。
1435 5
|
11月前
|
网络协议 Linux 网络安全
微软工程师偷偷在用!这款SSH工具让Windows操控CentOS比Mac还优雅!
远程登录Linux服务器是管理和维护服务器的重要手段,尤其在远程办公、云服务管理等场景中不可或缺。通过工具如XShell,用户可以方便地进行远程管理。SSH协议确保了数据传输的安全性,命令行界面提高了操作效率。配置XShell连接CentOS时,需确保Linux系统开启sshd服务和22端口,并正确设置主机地址、用户名和密码。此外,调整字体和配色方案可优化使用体验,解决中文显示问题。
486 21
微软工程师偷偷在用!这款SSH工具让Windows操控CentOS比Mac还优雅!
|
数据处理
「Mac畅玩鸿蒙与硬件45」UI互动应用篇22 - 评分统计工具
本篇将带你实现一个评分统计工具,用户可以对多个选项进行评分。应用会实时更新每个选项的评分结果,并统计平均分。这一功能适合用于问卷调查或评分统计的场景。
404 65
「Mac畅玩鸿蒙与硬件45」UI互动应用篇22 - 评分统计工具
|
11月前
|
自然语言处理 数据库 iOS开发
DBeaver Ultimate Edtion 25.0 Multilingual (macOS, Linux, Windows) - 通用数据库工具
DBeaver Ultimate Edtion 25.0 Multilingual (macOS, Linux, Windows) - 通用数据库工具
778 12
DBeaver Ultimate Edtion 25.0 Multilingual (macOS, Linux, Windows) - 通用数据库工具
|
项目管理 iOS开发 UED
Mac用户必备的任务管理软件!三款高效工具推荐
本文介绍了Mac系统在项目管理和任务管理方面的独特优势,包括用户体验、系统生态整合和隐私安全等方面。针对Mac用户的需求,推荐了三款高效任务管理软件:板栗看板、OmniFocus和Things 3。板栗看板适合团队协作,OmniFocus适合高需求的个人用户,Things 3则以简洁美观的界面和易用性著称。文章详细分析了每款软件的特点和适用场景,帮助用户选择最合适的工具。
821 6
|
iOS开发 索引 MacOS
mac文件搜索工具
【10月更文挑战第11天】
1269 2
|
小程序 开发者
微信开发者工具如何集成SVN、同时解决集成SVN无效果的问题
这篇文章介绍了如何在微信开发者工具中集成SVN版本控制系统,并提供了解决集成后无效果问题的方法。
微信开发者工具如何集成SVN、同时解决集成SVN无效果的问题

热门文章

最新文章