mirror of
				https://github.com/kepler155c/opus
				synced 2025-10-26 13:17:39 +00:00 
			
		
		
		
	cloud edit + logger removal
This commit is contained in:
		| @@ -1,133 +0,0 @@ | ||||
| local Logger = { | ||||
| 	fn = function() end, | ||||
| 	filteredEvents = { }, | ||||
| } | ||||
|  | ||||
| function Logger.setLogger(fn) | ||||
| 	Logger.fn = fn | ||||
| end | ||||
|  | ||||
| function Logger.disable() | ||||
| 	Logger.setLogger(function() end) | ||||
| end | ||||
|  | ||||
| function Logger.setDaemonLogging() | ||||
| 	Logger.setLogger(function (text) | ||||
| 		os.queueEvent('log', { text = text }) | ||||
| 	end) | ||||
| end | ||||
|  | ||||
| function Logger.setMonitorLogging() | ||||
| 	local debugMon = device.monitor | ||||
|  | ||||
| 	if not debugMon then | ||||
| 		debugMon.setTextScale(.5) | ||||
| 		debugMon.clear() | ||||
| 		debugMon.setCursorPos(1, 1) | ||||
| 		Logger.setLogger(function(text) | ||||
| 			debugMon.write(text) | ||||
| 			debugMon.scroll(-1) | ||||
| 			debugMon.setCursorPos(1, 1) | ||||
| 		end) | ||||
| 	end | ||||
| end | ||||
|  | ||||
| function Logger.setScreenLogging() | ||||
| 	Logger.setLogger(function(text) | ||||
| 		local x, y = term.getCursorPos() | ||||
| 		if x ~= 1 then | ||||
| 			local sx, sy = term.getSize() | ||||
| 			term.setCursorPos(1, sy) | ||||
| 			--term.scroll(1) | ||||
| 		end | ||||
| 		print(text) | ||||
| 	end) | ||||
| end | ||||
|  | ||||
| function Logger.setWirelessLogging() | ||||
| 	if device.wireless_modem then | ||||
| 		Logger.filter('modem_message') | ||||
| 		Logger.filter('modem_receive') | ||||
| 		Logger.filter('rednet_message') | ||||
| 		Logger.setLogger(function(text) | ||||
| 			device.wireless_modem.transmit(59998, os.getComputerID(), { | ||||
| 				type = 'log', contents = text | ||||
| 			}) | ||||
| 		end) | ||||
| 		Logger.debug('Logging enabled') | ||||
| 		return true | ||||
| 	end | ||||
| end | ||||
|  | ||||
| function Logger.setFileLogging(fileName) | ||||
| 	fs.delete(fileName) | ||||
| 	Logger.setLogger(function (text) | ||||
| 		local logFile | ||||
|  | ||||
| 		local mode = 'w' | ||||
| 		if fs.exists(fileName) then | ||||
| 			mode = 'a' | ||||
| 		end | ||||
| 		local file = io.open(fileName, mode) | ||||
| 		if file then | ||||
| 			file:write(text) | ||||
| 			file:write('\n') | ||||
| 			file:close() | ||||
| 		end | ||||
| 	end) | ||||
| end | ||||
|  | ||||
| function Logger.log(category, value, ...) | ||||
| 	if Logger.filteredEvents[category] then | ||||
| 		return | ||||
| 	end | ||||
|  | ||||
| 	if type(value) == 'table' then | ||||
| 		local str | ||||
| 		for k,v in pairs(value) do | ||||
| 			if not str then | ||||
| 				str = '{ ' | ||||
| 			else | ||||
| 				str = str .. ', ' | ||||
| 			end | ||||
| 			str = str .. k .. '=' .. tostring(v) | ||||
| 		end | ||||
| 		if str then | ||||
| 			value = str .. ' }' | ||||
| 		else | ||||
| 			value = '{ }' | ||||
| 		end | ||||
| 	elseif type(value) == 'string' then | ||||
| 		local args = { ... } | ||||
| 		if #args > 0 then | ||||
| 			value = string.format(value, unpack(args)) | ||||
| 		end | ||||
| 	else | ||||
| 		value = tostring(value) | ||||
| 	end | ||||
| 	Logger.fn(category .. ': ' .. value) | ||||
| end | ||||
|  | ||||
| function Logger.debug(value, ...) | ||||
| 	Logger.log('debug', value, ...) | ||||
| end | ||||
|  | ||||
| function Logger.logNestedTable(t, indent) | ||||
| 	for _,v in ipairs(t) do | ||||
| 		if type(v) == 'table' then | ||||
| 			log('table') | ||||
| 			logNestedTable(v) --, indent+1) | ||||
| 		else | ||||
| 			log(v) | ||||
| 		end | ||||
| 	end | ||||
| end | ||||
|  | ||||
| function Logger.filter( ...) | ||||
| 	local events = { ... } | ||||
| 	for _,event in pairs(events) do | ||||
| 		Logger.filteredEvents[event] = true | ||||
| 	end | ||||
| end | ||||
|  | ||||
| return Logger | ||||
| @@ -1,5 +1,4 @@ | ||||
| local Crypto   = require('crypto') | ||||
| local Logger   = require('logger') | ||||
| local Security = require('security') | ||||
| local Util     = require('util') | ||||
|  | ||||
| @@ -15,7 +14,6 @@ function socketClass:read(timeout) | ||||
| 	end | ||||
|  | ||||
| 	if not self.connected then | ||||
| 		Logger.log('socket', 'read: No connection') | ||||
| 		return | ||||
| 	end | ||||
|  | ||||
| @@ -64,7 +62,6 @@ end | ||||
|  | ||||
| function socketClass:close() | ||||
| 	if self.connected then | ||||
| 		Logger.log('socket', 'closing socket ' .. self.sport) | ||||
| 		self.transmit(self.dport, self.dhost, { | ||||
| 			type = 'DISC', | ||||
| 		}) | ||||
| @@ -113,7 +110,6 @@ function Socket.connect(host, port) | ||||
|  | ||||
| 	local socket = newSocket(host == os.getComputerID()) | ||||
| 	socket.dhost = tonumber(host) | ||||
| 	Logger.log('socket', 'connecting to ' .. port) | ||||
|  | ||||
| 	socket.transmit(port, socket.sport, { | ||||
| 		type = 'OPEN', | ||||
| @@ -138,8 +134,8 @@ function Socket.connect(host, port) | ||||
|  | ||||
| 				socket.dport = dport | ||||
| 				socket.connected = true | ||||
| 				Logger.log('socket', 'connection established to %d %d->%d', | ||||
| 															host, socket.sport, socket.dport) | ||||
| 				-- Logger.log('socket', 'connection established to %d %d->%d', | ||||
| 				--											host, socket.sport, socket.dport) | ||||
|  | ||||
| 				_G.transport.open(socket) | ||||
|  | ||||
| @@ -179,7 +175,7 @@ end | ||||
|  | ||||
| function Socket.server(port) | ||||
| 	device.wireless_modem.open(port) | ||||
| 	Logger.log('socket', 'Waiting for connections on port ' .. port) | ||||
| 	-- Logger.log('socket', 'Waiting for connections on port ' .. port) | ||||
|  | ||||
| 	while true do | ||||
| 		local _, _, sport, dport, msg = os.pullEvent('modem_message') | ||||
| @@ -203,7 +199,7 @@ function Socket.server(port) | ||||
| 					dhost = socket.dhost, | ||||
| 					shost = socket.shost, | ||||
| 				}) | ||||
| 				Logger.log('socket', 'Connection established %d->%d', socket.sport, socket.dport) | ||||
| 				-- Logger.log('socket', 'Connection established %d->%d', socket.sport, socket.dport) | ||||
|  | ||||
| 				_G.transport.open(socket) | ||||
| 				return socket | ||||
|   | ||||
| @@ -43,7 +43,7 @@ local buttons = { } | ||||
| local sx, sy = term.current().getSize() | ||||
| local maxRecent = math.ceil(sx * sy / 62) | ||||
|  | ||||
| local function elipse(s, len) | ||||
| local function ellipsis(s, len) | ||||
| 	if #s > len then | ||||
| 		s = s:sub(1, len - 2) .. '..' | ||||
| 	end | ||||
| @@ -253,7 +253,7 @@ function page.container:setCategory(categoryName, animate) | ||||
| 			icon = DEFAULT_ICON | ||||
| 		end | ||||
|  | ||||
| 		local title = elipse(program.title, 8) | ||||
| 		local title = ellipsis(program.title, 8) | ||||
|  | ||||
| 		local width = math.max(icon.width + 2, #title + 2) | ||||
| 		table.insert(self.children, UI.Icon({ | ||||
|   | ||||
							
								
								
									
										26
									
								
								sys/apps/cedit.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								sys/apps/cedit.lua
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| local multishell = _ENV.multishell | ||||
| local os         = _G.os | ||||
| local read       = _G.read | ||||
| local shell      = _ENV.shell | ||||
|  | ||||
| local args = { ... } | ||||
| if not args[1] then | ||||
|   error('Syntax: cedit <filename>') | ||||
| end | ||||
|  | ||||
| if not _G.cloud_catcher then | ||||
|   print('Paste key: ') | ||||
|   local key = read() | ||||
|   if #key == 0 then | ||||
|     return | ||||
|   end | ||||
|   -- open an unfocused tab | ||||
|   local id = shell.openTab('cloud ' .. key) | ||||
|   print('Connecting...') | ||||
|   while not _G.cloud_catcher do | ||||
|     os.sleep(.2) | ||||
|   end | ||||
|   multishell.setTitle(id, 'Cloud') | ||||
| end | ||||
|  | ||||
| shell.run('cloud edit ' .. table.unpack({ ... })) | ||||
							
								
								
									
										12
									
								
								sys/apps/cshell.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								sys/apps/cshell.lua
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,12 @@ | ||||
| local read       = _G.read | ||||
| local shell      = _ENV.shell | ||||
|  | ||||
| if not _G.cloud_catcher then | ||||
|   print('Paste key: ') | ||||
|   local key = read() | ||||
|   if #key == 0 then | ||||
|     return | ||||
|   end | ||||
|   print('Connecting...') | ||||
|   shell.run('cloud ' .. key) | ||||
| end | ||||
| @@ -1,3 +1,4 @@ | ||||
| fs.mount('sys/apps/pain.lua', 'urlfs', 'http://pastebin.com/raw/wJQ7jav0') | ||||
| fs.mount('sys/apps/update.lua', 'urlfs', 'http://pastebin.com/raw/UzGHLbNC') | ||||
| fs.mount('sys/apps/Enchat.lua', 'urlfs', 'https://raw.githubusercontent.com/LDDestroier/enchat/master/enchat3.lua') | ||||
| fs.mount('sys/apps/cloud.lua', 'urlfs', 'https://cloud-catcher.squiddev.cc/cloud.lua') | ||||
|   | ||||
| @@ -7,6 +7,11 @@ | ||||
| \030c\0317\151\131\0310\143\0317\131\0307\031c\148\ | ||||
| \0307\031c\138\030f\0317\151\131\131\131", | ||||
| 	}, | ||||
| 	[ "b2efeaa1a7d6d2185ea02473cf758203dfcea3fe" ] = { | ||||
| 		title = "Cloud", | ||||
| 		category = "Apps", | ||||
| 		run = "cshell.lua", | ||||
| 	}, | ||||
| 	[ "53ebc572b4a44802ba114729f07bdaaf5409a9d7" ] = { | ||||
| 		title = "Network", | ||||
| 		category = "Apps", | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 kepler155c@gmail.com
					kepler155c@gmail.com