Skip to content

Instantly share code, notes, and snippets.

@congard congard/CLionActivator.py
Last active Aug 15, 2019

Embed
What would you like to do?
CLion Linux Activator
import glob
import os
import shutil
import sys
from os.path import expanduser
# CLion Activator v1.1
# By congard
# https://github.com/congard
# http://congard.pp.ua/support-me
# mailto:dbcongard@gmail.com
# https://t.me/congard
# If you have an opportunity, please buy CLion: https://www.jetbrains.com/clion/buy/
home = expanduser("~")
# searching CLion folder
clionPath = glob.glob(home + "/.CLion*")
print("Found CLion folders:", *clionPath, ' ')
print("Enter folder index (by default 0)")
# you can specify default CLion folder by passing command-line argument - folder index
if len(sys.argv) > 1:
index = sys.argv[1]
print(index)
else:
index = input()
if index == '':
index = 0
index = int(index)
# removing evaluation key
key = glob.glob(clionPath[index] + "/config/eval/CLion*evaluation.key")[0]
print("Removing " + key)
os.remove(key)
# removing line which containing evlsprt
otherXml = clionPath[index] + "/config/options/other.xml"
print("Clearing evlsprt in " + otherXml)
print("Removing")
# reading other.xml
with open(otherXml, 'r') as file:
data = file.read()
# editing
data = data.split("\n")
newFile = ''
for i in range(len(data)):
if data[i].find("evlsprt") != -1:
print(data[i])
else:
newFile += data[i] + "\n"
# saving edited other.xml
with open(otherXml, "w") as file:
file.write(newFile)
# removing clion userPrefs directory
clionUserPrefs = home + "/.java/.userPrefs/jetbrains/clion"
print("Removing " + clionUserPrefs)
shutil.rmtree(clionUserPrefs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.