本文整理汇总了Python中module_locator.module_path函数的典型用法代码示例。如果您正苦于以下问题:Python module_path函数的具体用法?Python module_path怎么用?Python module_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了module_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_kmgdgis3D
def run_kmgdgis3D():
time.sleep(3)
exe = os.path.join(module_path().replace('\\script', '\\bin'), 'kmgdgis3D.exe')
if hasattr(sys, "frozen"):
exe = os.path.join(module_path(), 'kmgdgis3D.exe')
log('launching [%s]...' % exe)
p = Popen(exe)
示例2: modify_config_js
def modify_config_js():
path = os.path.join(module_path(), '..', 'data', 'www', 'js', 'config.js')
l = []
with open(path) as f:
for i in f.readlines():
if len(i.strip())>14 and i.strip()[:14] == 'var g_app_root':
root = os.path.join(module_path(), '..','data', 'www')
root = root.replace('\\','/')
g_app_root = 'var g_app_root = "file:///' + root + '";\r\n'
l.append(g_app_root)
elif len(i.strip())>20 and i.strip()[:20] == 'var g_local_tile_url':
g_local_tile_path = 'var g_local_tile_url = "%s";\r\n' % gConfig['map_local_tiles_url']
l.append(g_local_tile_path)
elif "var g_default_basemap" in i:
if len(gConfig['map_local_tiles_url'])>0:
l.append("var g_default_basemap = 'basemap_esrilocal';\r\n")
else:
l.append("var g_default_basemap = 'basemap_googlesat';\r\n")
elif "'basemap_esrilocal':'本地地图'," in i:
if len(gConfig['map_local_tiles_url'])>0:
l.append("\t'basemap_esrilocal':'本地地图',\r\n")
else:
l.append("\t//'basemap_esrilocal':'本地地图',\r\n")
else:
l.append(i)
s = ''
for i in l:
s += dec(i)
#print(s)
with open(path, 'w') as f:
f.write(enc(s))
示例3: Arc2GeoJsonTunnel
def Arc2GeoJsonTunnel(name):
path = os.path.join(module_path(), JSON_DIR, 'arcjson_tunnel_%s.json' % name)
arcjson = None
if os.path.exists(path):
with open(path) as f:
arcjson = json.loads(f.read())
if arcjson:
offsetx, offsety = CalcOffset(name)
obj = {}
obj['type'] = 'FeatureCollection'
obj['features'] = []
for feature in arcjson['features']:
for path in feature['geometry']['paths']:
o = {}
o['type'] = 'Feature'
o['properties'] = {}
o['geometry'] = {}
o['geometry']['type'] = 'LineString'
o['geometry']['coordinates'] = []
for point in path:
lng, lat = ToGeographic(point[0] + offsetx, point[1] + offsety)
o['geometry']['coordinates'].append([lng, lat])
obj['features'].append(o)
path = '%s/geojson_tunnel_%s.json' % (JSON_DIR, name)
with open(path, 'w') as f:
f.write(json.dumps(obj, ensure_ascii=True, indent=4) + '\n')
示例4: show_help
def show_help(self):
""" Purpose: This is called when the user selects the 'Help Text' menubar option. It opens the README.html file
in their default browser. If the file doesn't exist it opens the github readme page instead.
"""
# Grab the directory where the script is running.
readme = module_path()
# Determine our OS, attach the README.html file to the path, and open that file.
if sys.platform.startswith('darwin'):
readme += "/README.html"
if os.path.isfile(readme):
subprocess.call(('open', readme))
else:
try:
webbrowser.open('https://github.com/nprintz/jaide')
except webbrowser.Error:
pass
elif os.name == 'nt':
readme += "\\README.html"
if os.path.isfile(readme):
os.startfile(readme) # this works on windows, not sure why pylint shows an error.
else:
try:
webbrowser.open('https://github.com/nprintz/jaide')
except webbrowser.Error:
pass
elif os.name == 'posix':
readme += "/README.html"
if os.path.isfile(readme):
subprocess.call(('xdg-open', readme))
else:
try:
webbrowser.open('https://github.com/nprintz/jaide')
except webbrowser.Error:
pass
示例5: Activated
def Activated(self):
import os
try:
from . import module_locator
except:
import module_locator
try:
from CadQuery.CQGui import ImportCQ
except:
from CQGui import ImportCQ
module_base_path = module_locator.module_path()
import cadquery
from PySide import QtGui, QtCore
msg = QtGui.QApplication.translate(
"cqCodeWidget",
"CadQuery " + cadquery.__version__ + "\r\n"
"CadQuery is a parametric scripting API "
"for creating and traversing CAD models\r\n"
"Author: David Cowden\r\n"
"License: Apache-2.0\r\n"
"Website: https://github.com/dcowden/cadquery\r\n",
None)
FreeCAD.Console.PrintMessage(msg)
#Getting the main window will allow us to start setting things up the way we want
mw = FreeCADGui.getMainWindow()
dockWidgets = mw.findChildren(QtGui.QDockWidget)
for widget in dockWidgets:
if widget.objectName() == "Report view":
widget.setVisible(True)
示例6: show_examples
def show_examples(self):
""" Purpose: This method opens the example folder for the user, or open the github page for the example folder.
"""
# Grab the directory that the script is running from.
examples = module_path()
# Determin our OS, attach the README.html file to the path, and open that file.
if sys.platform.startswith('darwin'):
examples += "/examples/"
if os.path.isdir(examples):
subprocess.call(('open', examples))
else:
try:
webbrowser.open('https://github.com/nprintz/jaide/examples')
except webbrowser.Error:
pass
elif os.name == 'nt':
examples += "\\examples\\"
if os.path.isdir(examples):
os.startfile(examples) # this works on windows, not sure why pylint shows an error.
else:
try:
webbrowser.open('https://github.com/nprintz/jaide/examples')
except webbrowser.Error:
pass
elif os.name == 'posix':
examples += "/examples/"
if os.path.isdir(examples):
subprocess.call(('xdg-open', examples))
else:
try:
webbrowser.open('https://github.com/nprintz/jaide/examples')
except webbrowser.Error:
pass
示例7: Activated
def Activated(self):
FreeCAD.Console.PrintMessage(self.exFile + "\r\n")
#So we can open the "Open File" dialog
mw = FreeCADGui.getMainWindow()
#Start off defaulting to the Examples directory
module_base_path = module_locator.module_path()
exs_dir_path = os.path.join(module_base_path, 'Examples')
#We need to close any file that's already open in the editor window
CadQueryCloseScript().Activated()
#Append this script's directory to sys.path
sys.path.append(os.path.dirname(exs_dir_path))
#We've created a library that FreeCAD can use as well to open CQ files
ImportCQ.open(os.path.join(exs_dir_path, self.exFile))
docname = os.path.splitext(os.path.basename(self.exFile))[0]
FreeCAD.newDocument(docname)
#Execute the script
CadQueryExecuteScript().Activated()
#Get a nice view of our model
FreeCADGui.activeDocument().activeView().viewAxometric()
FreeCADGui.SendMsgToActiveView("ViewFit")
示例8: get_backlinks
def get_backlinks(onion_url):
""" Call backlink tester and return the number of backlinks. """
my_path = module_locator.module_path()
backlink_tool = my_path + "/backlinkers.py"
args = ["python", backlink_tool, "-c", onion_url] # TODO: use the new backlinker spider instead?
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
count = int(proc.communicate()[0])
return count
示例9: Activated
def Activated(self):
module_base_path = module_locator.module_path()
templ_dir_path = os.path.join(module_base_path, 'Templates')
# Use the library that FreeCAD can use as well to open CQ files
ImportCQ.open(os.path.join(templ_dir_path, 'script_template.py'))
FreeCAD.Console.PrintMessage("Please save this template file as another name before creating any others.\r\n")
示例10: GetDeviceList
def GetDeviceList():
ret = []
path = os.path.join(module_path(), JSON_DIR)
for i in os.listdir(path):
p = os.path.join(path, i)
if os.path.isfile(p) and 'arcjson_device_' in i:
ret.append(i.replace('arcjson_device_', '').replace('.json', ''))
return ret
示例11: save_popularity_data
def save_popularity_data(data, onion_id):
""" Save the popularity data to """
my_path = module_locator.module_path()
document_dir = my_path.replace("/tools", "/popularity_stats/")
document_dir = document_dir + datetime.datetime.now().strftime("%y-%m-%d")
if not os.path.exists(document_dir):
os.makedirs(document_dir)
pretty_data = valid_pretty_json(data)
text2file(pretty_data, document_dir + "/" + onion_id + ".json")
示例12: main
def main():
"""Main function."""
my_path = module_locator.module_path()
json_data_dir = my_path.replace("/tools", "/tor2web_stats/")
onions_data = {}
for filename in os.listdir(json_data_dir):
if filename.endswith(".json"):
json_file = json_data_dir + filename
json_data = open(json_file)
day_data = json.load(json_data)
json_data.close()
time_stamp = day_data["date"].encode("ascii", "ignore")
for onion_data in day_data["hidden_services"]:
onion = onion_data["id"].lower()
access_count = int(onion_data["access_count"])
try:
found = False
last_time_stamp = onions_data[onion]#[-1].keys()[0]
for o in onions_data[onion]:
if o.keys()[0] == time_stamp:
o[time_stamp] = o[time_stamp] + access_count
found = True
break
if not found:
onions_data[onion].append({time_stamp: access_count})
except:
onions_data[onion] = []
onions_data[onion].append({time_stamp: access_count})
static_log = my_path.replace("/tools", "/ahmia/static/log/onion_site_history/")
onions = []
# Filter banned domains, get the list first
r = requests.get('https://127.0.0.1/banneddomains.txt', verify=False)
text = r.text.encode('ascii')
text = text.replace("http://", "")
text = text.replace("https://", "")
text = text.replace(".onion/", "")
ban_list = text.split("\n")
# Print to files
for onion in onions_data.keys():
data = onions_data[onion]
# Only show those onions that have over 100 active days
# Filter out banned domains
if len(data) > 100 and not onion in ban_list:
onions.append(onion)
if not onion in ban_list:
data = sorted(data, key=getKey)
pretty = json.dumps(data, indent=4, ensure_ascii=False)
file = open(static_log + onion + ".json", "w")
file.write(pretty+"\n")
file.close()
onions.sort()
pretty = json.dumps(onions, indent=4, sort_keys=True, ensure_ascii=False)
file = open(static_log + "onions.json", "w")
file.write(pretty+"\n")
file.close()
示例13: init_tunnel_name_file
def init_tunnel_name_file():
ret = {}
d = os.path.join(module_path(), DATA_DOCS_DIR)
path = os.path.join(d, gConfig['xls_tunnel_main'])
book = xlrd.open_workbook(path)
sheet = book.sheet_by_name(u'隧道文件对应')
row, col = find_boundary(sheet)
for i in range(row+1):
ret[sheet.cell_value(i,0)] = sheet.cell_value(i,1)
return ret
示例14: loader
def loader(tor2web_nodes):
"""Load visited domains information from tor2web nodes."""
my_path = module_locator.module_path()
filename = my_path.replace("/tools", "/ahmia/static/log/")
for node in tor2web_nodes:
print "\n Trying download from the %s \n" % node
md5list = get_md5list("abcd." + node)
if md5list:
filename = filename + node + "_md5filterlist.txt"
text2file(md5list, filename)
示例15: CalcOffset
def CalcOffset(name):
offsetx, offsety = 0, 0
path = os.path.join(module_path(), JSON_DIR, 'tunnel_boundry_%s.json' % name)
boundry = None
if os.path.exists(path):
with open(path) as f:
boundry = json.loads(f.read())
if boundry:
mercstartx, mercstarty = ToWebMercator(boundry['lnglat']['startx'], boundry['lnglat']['starty'])
offsetx, offsety = mercstartx - boundry['dwg_mercator']['startx'], mercstarty - boundry['dwg_mercator']['starty']
return offsetx, offsety